Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ld de,0;the command char pointer
- exx ; switch bc , de and hl with their shadow ones
- ld b,1 ; the command char pointer for the bit instruction. it counts as bits so 1=00000001 2=00000010 3=00000100
- ld c,0 ; the blacklist
- exx ; go back to the normal bc de and hl
- ld iy,COMMAND_TABLE; iy beacaus we can use it as a pointer to something with an offset in hust 2 bytes!
- ld hl,COMMAND_TABLE
- call wait_for_a_key_and_then_put_it_in_the_c_register_without_modfying_any_other_register
- xor 13 ; is it the ascii code for carrage return?
- jr z,done ; our job is done, the shadow c holds the blacklist
- ld b,(iy+1) ; get the pointer to the string of the commands from the COMMAND_TABLE to bc
- ld c,(iy+0)
- ld ix,0 ; move bc to ix
- add ix,bc
- add ix,de ; move the pointer of the string to the current char peing read
- ld a,(ix+0) ; load the char from the current string and the current offset
- xor b ; if b ( the char from the keyboard ) == a , the the zero flag will be set
- jr z,SKIP_BLACKLIST
- exx
- ld a,c
- or b ; now the bit corresponding the current command is set
- rlc c ; shift c one bit left , bit 7 goes to bit 0 and carry
- exx
- inc iy ; we haven't finished checking the 8 commands
- inc iy ; go to the next command in the COMMAND_TABLE
- jr c,checknextchar ; if carry is set then we have gone through all bits of c so all 8 commands
- jr loop
- checknextchar:
- inc de ; check the new chars
- ld iy,COMMAND_TABLE ; lets check the first command first
- jr loop
- COMMAND_TABLE: ; make an array with pointers to the strings
- COMMAND0
- COMMAND1
- COMMAND2
- COMMAND3
- COMMAND4
- COMMAND5
- COMMAND6
- COMMAND7
- COMMAND0:.dm "reset",0xff ; the keyboard wont enter 0xff right?
- COMMAND1:.dm "poke",0xff ; null terminated strings
- COMMAND2:.dm "peek",0xff
- COMMAND3:.dm "boot_fuzix",0xff
- COMMAND4:.db 0xFF
- COMMAND5:.db 0xFF
- COMMAND6:.db 0xFF
- COMMAND7:.db 0xFF
- done: ; inspec the shadow c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement