109 lines
1.8 KiB
Z80 Assembly
109 lines
1.8 KiB
Z80 Assembly
;;;;;;;;;;;;;;;;;;; HEADER ;;;;;;;;;;;;;;;;;;;
|
|
read "\SrcCPC\winape_macros.asm"
|
|
read "\SrcCPC\MemoryMap.asm"
|
|
read "\SrcALL\winapeBuildCompat.asm"
|
|
;;;;;;;;;;;;;;;;;;; PROGRAM ;;;;;;;;;;;;;;;;;;;
|
|
|
|
org &1000
|
|
|
|
ld hl,namegame
|
|
ld de,name1
|
|
call PrintString_NameGame
|
|
|
|
|
|
ld hl,namegame
|
|
ld de,name2
|
|
call PrintString_NameGame
|
|
|
|
|
|
ld hl,namegame
|
|
ld de,name3
|
|
call PrintString_NameGame
|
|
|
|
ret ;return to basic
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
PrintString_NameGame:
|
|
ld a,(hl)
|
|
or a ;compare to zero
|
|
ret z ;exit on null terminator
|
|
cp '?'
|
|
jr z,printNameAsIs
|
|
cp '%'
|
|
jr z,insertName
|
|
;else, just print what you see.
|
|
call &bb5a ;amstrad CPC kernel will print the contents of A as an ascii character
|
|
|
|
continue_NameGame:
|
|
inc hl
|
|
jr PrintString_NameGame
|
|
;;;;;;;;;;;;;;;; execution will never fall through this line without a jump
|
|
printNameAsIs:
|
|
ex de,hl
|
|
push hl
|
|
call PrintString
|
|
pop hl
|
|
ex de,hl
|
|
jr continue_NameGame
|
|
;;;;;;;;;;;;;;;; execution will never fall through this line without a jump
|
|
insertName:
|
|
push hl
|
|
dec hl
|
|
dec hl
|
|
dec hl
|
|
ld c,(hl) ;get the b in "bo-%", or the f in "fo-%", etc.
|
|
pop hl
|
|
ex de,hl ;swap to the name we wish to print
|
|
push hl
|
|
ld a,(hl)
|
|
cp c
|
|
jr z,dontPrintC
|
|
cp 'a'
|
|
jr z,beginsWithVowel
|
|
cp 'e'
|
|
jr z,beginsWithVowel
|
|
cp 'i'
|
|
jr z,beginsWithVowel
|
|
cp 'o'
|
|
jr z,beginsWithVowel
|
|
cp 'u'
|
|
|
|
ld a,c
|
|
call PrintChar
|
|
dontPrintC:
|
|
inc hl
|
|
call PrintString
|
|
pop hl
|
|
ex de,hl
|
|
jr continue_NameGame
|
|
|
|
beginsWithVowel:
|
|
;if name begins with vowel, we print C then the name as-is
|
|
ld a,c
|
|
call PrintChar
|
|
call PrintString ;print name as is
|
|
|
|
pop hl
|
|
ex de,hl
|
|
jr continue_NameGame
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
PrintString:
|
|
ld a,(hl)
|
|
or a
|
|
ret z
|
|
call &BB5A
|
|
inc hl
|
|
jr PrintString
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
name1:
|
|
db "gary",0
|
|
name2:
|
|
db "earl",0
|
|
name3:
|
|
db "billy",0
|
|
|
|
namegame:
|
|
db "?, ?, bo-%",13,10
|
|
db "banana-fana fo-%",13,10
|
|
db "fee-fi-mo-%",13,10
|
|
db "?!",13,10,13,10
|
|
db 0
|