The Name Game: Difference between revisions
Content added Content deleted
(→{{header|Picat}}: Adding Picat) |
Puppydrum64 (talk | contribs) |
||
Line 1,708: | Line 1,708: | ||
Steve! |
Steve! |
||
</pre> |
</pre> |
||
=={{header|MIPS Assembly}}== |
|||
The cartridge header and print routines were omitted so that the reader can focus on the logic. |
|||
<lang mips> la $a0,theNameGame |
|||
la $s0,theName |
|||
jal PrintString_NameGame |
|||
nop |
|||
jal NewLine |
|||
nop |
|||
la $a0,theNameGame |
|||
la $s0,theName2 |
|||
jal PrintString_NameGame |
|||
nop |
|||
jal NewLine |
|||
nop |
|||
la $a0,theNameGame |
|||
la $s0,theName3 |
|||
jal PrintString_NameGame |
|||
nop |
|||
jal NewLine |
|||
nop |
|||
shutdown: |
|||
nop ;project 64 detects an infinite loop and throws an error, unless an extra nop is here. |
|||
b shutdown |
|||
nop |
|||
PrintString_NameGame: |
|||
pushall |
|||
DrawChars_NameGame: |
|||
lbu a1,0(a0) ;Load a character |
|||
.ifdef buildPSX |
|||
nop ;load delay slot - not needed on MIPS III or higher |
|||
.endif |
|||
beqz a1,PrintString_Done ;Done? |
|||
nop |
|||
li $a2,'%' |
|||
bne $a1,$a2,skip_NameGameLC |
|||
nop |
|||
jal insertNameLetterChange |
|||
nop |
|||
addiu a0,1 |
|||
b DrawChars_NameGame |
|||
nop |
|||
skip_NameGameLC: |
|||
li $a2,'?' |
|||
bne $a1,$a2,skip_NameGameAsIs |
|||
nop |
|||
jal insertName |
|||
nop |
|||
addiu a0,1 |
|||
b DrawChars_NameGame |
|||
nop |
|||
skip_NameGameAsIs: |
|||
li $a2,10 |
|||
bne $a1,$a2,skip_Linefeed |
|||
nop |
|||
jal NewLine |
|||
nop |
|||
skip_Linefeed: |
|||
addiu a0,1 ;branch delay slot - Move to next Char |
|||
jal PrintChar ;Show Character A0 to the screen |
|||
nop |
|||
j DrawChars_NameGame ;Repeat |
|||
nop |
|||
PrintString_Done_NameGame: |
|||
popall |
|||
jr ra |
|||
nop |
|||
insertName: |
|||
push a0 |
|||
push ra |
|||
move $a0,$s0 |
|||
jal PrintString |
|||
nop |
|||
pop ra |
|||
pop a0 |
|||
jr ra |
|||
nop |
|||
insertNameLetterChange: |
|||
push a0 |
|||
push ra |
|||
subiu $a0,3 |
|||
lbu $a1,($a0) ;we may need to replace the first letter of the name with this character. |
|||
.ifdef buildPSX |
|||
nop ;load delay slot - not needed on MIPS III or higher |
|||
.endif |
|||
move $a0,$s0 |
|||
lbu $a2,($a0) |
|||
.ifdef buildPSX |
|||
nop ;load delay slot - not needed on MIPS III or higher |
|||
.endif |
|||
beq $a1,$a2,skipFirstLetter |
|||
nop |
|||
jal PrintChar |
|||
nop |
|||
skipFirstLetter: |
|||
;now we check if the $a2 is a vowel, if it is, skip the addiu |
|||
li $a3,'a' |
|||
beq $a3,$a2,FirstLetterIsVowel |
|||
nop |
|||
li $a3,'e' |
|||
beq $a3,$a2,FirstLetterIsVowel |
|||
nop |
|||
li $a3,'i' |
|||
beq $a3,$a2,FirstLetterIsVowel |
|||
nop |
|||
li $a3,'o' |
|||
beq $a3,$a2,FirstLetterIsVowel |
|||
nop |
|||
li $a3,'u' |
|||
beq $a3,$a2,FirstLetterIsVowel |
|||
nop |
|||
addiu $a0,1 |
|||
FirstLetterIsVowel: |
|||
jal PrintString |
|||
nop |
|||
pop ra |
|||
pop a0 |
|||
jr ra |
|||
nop |
|||
theName: |
|||
.ascii "gary" |
|||
.byte 0 ;null terminator |
|||
.align 4 |
|||
theName2: |
|||
.ascii "earl" |
|||
.byte 0 |
|||
.align 4 |
|||
theName3: |
|||
.ascii "billy" |
|||
.byte 0 |
|||
.align 4 |
|||
theNameGame: |
|||
.ascii "?,?,bo-%" |
|||
.byte 10 ;line feed |
|||
.ascii "banana-fana fo-%" |
|||
.byte 10 |
|||
.ascii "fee-fi-mo-%" |
|||
.byte 10 |
|||
.ascii "?!" |
|||
.byte 0 |
|||
.align 4</lang> |
|||
{{out}} |
|||
[https://ibb.co/V9GcTFV Screenshot of emulator] |
|||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |