Day 12: 353 days left..
With the anykey subroutine doing a good job of not crashing the program. It was time to get a little more precise/discerning with the keyboard input. Debugging the fallout from the following code will probably take up a lot of the project time today. But without it there is no real interaction beyond anykey on the menus (and later the main game). So it pays to get this right as soon as possible.
The code is from Chuntey blog.
https://chuntey.wordpress.com/2012/12/1 ... chapter-2/ I adapted it to call the various menus instead of up,down.left,right. Now me at 3am in the morning probably was more potato than me fully refreshed so lets hope I can see the obvious errors that were hanging the program and making it unresponsive.
First the code.
this is the main.asm for crapchess
Code: Select all
org 50000
include "changebordercolour.asm"
include "changeinkpaper.asm"
include "mainmenu.asm"
include "keyboard.asm"
include "clearscreen.asm"
include "splashscreen.asm"
include "soundfx.asm"
include "random.asm"
Main:
call randomChuntey
and 7
call rndSoundFXGen
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call splashScreen
call keyboardAnyKPress
call wiggy
call blp1
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call mainMenuScreen
; call keyboardAnyKPress
call wiggy
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call gameMenuScreen
call keyboardAnyKPress
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call aboutMenuScreen
call keyboardAnyKPress
call wiggy
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call soundMenuScreen
call keyboardAnyKPress
call wiggy
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call controlsMenuScreen
call keyboardAnyKPress
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call helpMenuScreen
call keyboardAnyKPress
call wiggy
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call randomChuntey
and 255
call changeInkPaper
call clearScreenRom
call attractScreen
call keyboardAnyKPress
call wiggy
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call clearScreenRom
call quitMenuScreen
call keyboardAnyKPress
call rndSoundFXGen
call randomChuntey
and 7
call changeBorderColour
call clearScreenRom
call highScoreMenu
ld (51000),a
jp Main
ret
end Main
this is the mainmenu.asm - where the information about the main menu screen lives
Code: Select all
include "test.asm"
include "helpmenu.asm"
include "controlsmenu.asm"
include "gamemenu.asm"
include "soundmenu.asm"
include "aboutmenu.asm"
include "quitmenu.asm"
include "highscoremenu.asm"
mainMenuScreen:
ld a, 2
call 5633
ld de, mainMenuString
ld bc, eostr2-mainMenuString
call 8252
call keyboardTest1234
ret
mainMenuString: defb 22,2,8,"Main Menu screen."
defb 13,"1:MENU 1"
defb 13,"2:MENU 2"
defb 13,"3:MENU 3"
defb 13,"4:MENU 4"
defb 13,"5:MENU 5"
defb 13,"6:MENU 6"
defb 13,"7:MENU 7"
eostr2: equ $
this is the keyboard.asm file. Where all the keyboard input subroutines live.
as a sanity check I did a direct copy paste from the blog, and just replace the subroutine jumps to my program menus. (keyboardTest1234)..
Code: Select all
keyboardAnyKPress:
ld hl,23560 ; LAST K system variable.
ld (hl),0 ; put null value there
_loop:
ld a,(hl) ; new value of LAST K.
cp 0 ; is it still zero?
jr z,_loop ; yes, so no key pressed.
ret ; key was pressed.
keyboardTest1234:
ld bc,63486 ; keyboard row 1-5/joystick port 2.
in a,(c) ; see what keys are pressed.
rra ; outermost bit = key 1.
push af ; remember the value.
call nc,aboutMenuScreen ; it's being pressed, move left.
pop af ; restore accumulator.
rra ; next bit along (value 2) = key 2.
push af ; remember the value.
call nc,gameMenuScreen ; being pressed, so move right.
pop af ; restore accumulator.
rra ; next bit (value 4) = key 3.
push af ; remember the value.
call nc,soundMenuScreen ; being pressed, so move down.
pop af ; restore accumulator.
rra ; next bit (value 8) reads key 4.
call nc,controlsMenuScreen ; it's being pressed, move up.
ret
keyboardTest12345:
ld bc,63486 ; keyboard row 1-5/joystick p2
in a,(c) ; see what keys are pressed
rra ; outermost bit = key 1
push af ; remember the value
call nc,aboutMenuScreen ; its being pressed - load about menu
pop af ; restore accumulator
rra ; next bit along (value2) = key 2
push af ; remember the value
call nc,gameMenuScreen ; its being pressed - load game menu
pop af ; restore accumulator
rra ; next bit along (value4) = key 3
push af ; remember the value
call nc,soundMenuScreen ; its being pressed - load sound menu
pop af ; restore accumulator
rra ; next bit along (value8) = key 4
push af ; remember the value
call nc,controlsMenuScreen ; its being pressed - load control main
pop af ; restore accumulator
rra ; next bit along (value16) = key 5
push af ; remember the value
call nc,helpMenuScreen ; its being pressed - load help menu
ret
when keyboardTest12345 is called none of the keys respond...
have the menu screen set a memory location to hold the subroutines in order like.
CHOICE1, CHOICE2, CHOICE3, CHOICE4, CHOICE5
then calls the keyboard input subroutine,
the subroutine looks at memory location X, then if key 1 is pressed, call subroutine from memory location[1]
the subroutine looks at memory location X, then if key 2 is pressed, call subroutine from memory location[2]
the subroutine looks at memory location X, then if key 3 is pressed, call subroutine from memory location[3]
the subroutine looks at memory location X, then if key 4 is pressed, call subroutine from memory location[4]
the subroutine looks at memory location X, then if key 5 is pressed, call subroutine from memory location[5]
That way I could have menu key input as a subroutine, and just pass the subroutines for the calls to the memory location for each menu page. Making things a lot more tidy if you see what I mean.
I think these would be described as 'jump tables'
Another weird issue I have been having is trying to get fuse to load the outlet microdrives from the archive. There are some nice programs contained in this magazine but most of the issues are distributed as microdrive only. is there a way I can load these into fuse?
A fair question is ... why bother searching the archives for 'skillz', well using my potato logic mostly derived from Dragonlance novels: I equate the archive to being a similar situation with finding the ancient tombs + Fistandantilus spell books. But saying 'nah bro.. who needs that..'
Just browsing I notice there are routines for screen wipes, scrolls and other interesting effects that would make my projects look better. my plan was to scour the archive for every useful assembly routine/technique and compile them into a wiki. If the 'skills' were arranged in modular form it would be pretty useful and furthermore could only help me learn.
The plan was to go from this..
to this...
with Assembly gains
Any tips to good assembly routines in the archives would be appreciated.