Here is the updated version of my z80 code for this. Uncomment the "#define KERM" to use the Merthing @ Kerm extension.
Code: ; Program Name:
; Author:
; Version:
; Date:
; Written for Doors CS 7.0 and higher (http://dcs.cemetech.net)
#define store(xx,yyyy) ld a,xx \ ld (yyyy),a
#define storelarge(value,location) ld hl,value \ ld (location),hl
#define clrscr() ld hl,gbuf \ ld de,gbuf+1 \ ld bc,767 \ ld (hl),0 \ ldir
#define comparehl(xxxx) ld de,xxxx \ or a \ sbc hl,de \ add hl,de
#define comparehlde() or a \ sbc hl,de \ add hl,de
#define getKey(group,bitty) ld a,group \ out (1),a \ nop \ nop \ in a,(1) \ bit bitty,a
#define sprite(sprite,x,y,height) ld ix,sprite \ ld a,(y) \ ld l,a \ ld a,(x) \ ld b,height \ call iPutSprite
#define AddBullet(x,y) ld a,(y) \ld e,a \ ld a,(x) \ call AddBullet
#define copybackwards(start,size) ld hl,start \ ld bc,size \ push hl \ pop de \ inc de \ ldir
#define setmem(start,size,value) ld hl,start \ ld de,start+1 \ ld bc,size-1 \ ld (hl),value \ ldir
#define random(low,high) ld b,high-low+1 \ call iRandom \ add a,low
#define random(high) ld b,high \ call iRandom
#define randombool() ld a,r \ and %00000001
#define randomjump(jr1, jr2) ld a,r \ and %0000001 \ jr z,jr1 \ jr jr2
#define randomjump(jr1) ld a,r \ and %00000001 \ jr z,jr1
#define copy(from,to,size) ld hl,from \ ld de,to \ ld bc,size \ ldir
;#define KERM
#define ARRAY_SIZE 5
#ifdef KERM
#define ARRAY_SIZE 6
#endif
#define hflagison() ld a,(hflag) \ or a \ ret nz
.nolist
#include "dcs7brass.inc"
.list
.org progstart
.db $BB,$6D
Init:
xor d
ret
jr Start
.dw 0000 ;or .dw $0000 if you don't have a description '
.db $07,$00 ;always this string
.dw 0000 ;or .dw $0000 if you don't have an icon'
.dw 0000 ;usually .dw $0000 if you don't have or know what an ALE is'
Start: ;main routines
store(0,accum)
store(0,hflag)
ld hl,varname
rst 20h
bcall 42F1h ;ChkFindSym
jr c,Archived ;carry flag is set if the VAT entry is not found
ex de,hl ;put data pointer into hl
xor a
cp b ;see if b is 0, and the program is in the ram
jr z,unarchived ;if so, jump to unarchived
Archived:
Error:
bcall _ClrLCDFull
ld hl,sErrorMessage
bcall _PutS
bcall _Getkey
ret
Unarchived:
inc hl
inc hl
Merthterpreter:
ld a,(hl)
push hl
push bc
ld b,ARRAY_SIZE
ld hl,ArrayToTestAgainst
CheckForCharacterLoop:
cp (hl)
jr z,CheckForCharacter_Found
CheckForCharacterNevermind:
inc hl
inc hl
inc hl
CheckForCharacterContinue:
djnz CheckForCharacterLoop
jr CheckForCharacterFinished
CheckForCharacter_Found:
inc hl
push hl
ld ($+3+1),hl
ld hl,(0000) ; SMC
ld ($+3+1),hl
call 0000 ; SMC
pop hl
inc hl
inc hl
jr CheckForCharacterContinue
CheckForCharacterFinished:
pop bc
pop hl
inc hl
dec bc
ld a,b
or c
ret z
jr Merthterpreter
MertheseM:
hflagison()
#ifdef KERM
randomjump(MertheseM2)
#endif
ld hl,sMerth
bcall _PutS
ret
#ifdef KERM
MertheseM2:
ld h,0
ld a,(accum)
ld l,a
bcall _DispHL
ret
#endif
MertheseE:
hflagison()
#ifdef KERM
randomjump(MertheseE2)
#endif
ld a,'\n'
bcall _PutC
ret
#ifdef KERM
MertheseE2:
ld hl,accum
inc (hl)
ret
#endif
MertheseR:
hflagison()
#ifdef KERM
randomjump(MertheseR2)
#endif
ld a,' '
bcall _PutC
ret
#ifdef KERM
MertheseR2:
xor a
ld (accum),a
ret
#endif
MertheseT:
hflagison()
random(14) ; Because ASM doesn't have 13.4, sorry :('
ld b,a
MertheseTLoop:
push bc
random('a','z')
bcall _PutC
pop bc
djnz MertheseTLoop
ret
MertheseH:
ld a,(hflag)
xor 1
ld (hflag),a
ret
#ifdef KERM
MertheseK:
hflagison()
ld a,(accum)
bcall _PutC
ret
#endif
data:
ArrayToTestAgainst:
.db 'M', MertheseM
.db 'E', MertheseE
.db 'R', MertheseR
.db 'T', MertheseT
.db 'H', MertheseH
#ifdef KERM
.db 'K', MertheseK
#endif
hflag:
.db 0
sMerth:
.db "merth",0
sErrorMessage:
.db "Please unarchive"
.db "prgmMERTHCDE",0
VarName:
.db $05,"MERTHCDE",0
accum:
.db 0