The object is to design part of a numbers game (it's for uni, i've been working for about 2 days solid on this and i'm still not getting it)
i've got the clearing of the screen, and the basic structure along with some array usage down, but my subroutines keep pointing back to the start of my program and not to where the subroutine was called from.
The idea is to have the program in a permenant loop that does the following:
1. moves numbers down 1 row on the screen
2. decides if it needs to indroduce another number based on a randomised (with limits)countdown timer and adds it into the array accordingly (the value and column position is also random)
3. when a number reaches the bottom (row position 20) it moves it back to position 1.
Here's the code i've got so far, i swear i've redone this like 4 or 5 times (the first attempt was so dismal i decided it best to just delete it and start afresh)
All the comments that say 'should be 54' and whatnot i've reduced to 2 for the purposes of stepping through the program.
numcols .equ 54 numrows .equ 20 clra clrb ldx enemyval ldab #2; should be 54 resetenemies ldaa #0 staa enemyrow,x inx decb bne resetenemies ldab #2; should be 54 resetenemyval ldaa #0 staa enemyval,x inx decb bne resetenemyval ldaa #2 jsr randomnumber ldab randno; then multiply X 2 staa countdown engineloop jsr clearscreen; the game engine loop ldaa #54 staa updatecount; loads 54 colums for the update subroutine jsr updateenemies braland ldaa #2 jsr checknewenemy bne engineloop clearscreen ldaa #1 clrscrn ldx #screen stx pcaret ;reset caret ldaa #$41 staa 0,x staa 54,x staa 2,x staa 3,x csnlp1 clr 0,x ;[x] = 0 inx ;x++ cpx $FEE8 ;screen+1000 bne csnlp1 ;loop bra braland ;return ;------------------------- updateenemies ldx #enemyval ldaa enemyval,x staa a ldx #enemyrow ldab enemyrow,x stab y tsta bgt removing removing ldx #screen ldaa #$30 staa y,x ; writes blank to position of old number ldaa y inca ; adds 1 to the current row, giving the next row staa y ldaa #a ; loads the enemyvalue staa y,x; writes enemyvalue onto the correct screen position ldaa y cmpa #19 bgt movenumberup ; if y > 19, move it to the top row again ready for the next redraw jmp endif movenumberup ldaa #0 staa enemyrow,x; sets the row position that was 20 back to 0 (the top row) endif inx ldaa updatecount; loads the counter which is 54 deca staa updatecount tsta bne updateenemies; loops back to the top rts ;;;;;;;;;;;;;;;;;;; checknewenemy ldaa countdown deca staa countdown tsta bne addnewenemy; if countdown is 0, then go to the addnewenemies function rts addnewenemy jsr randomnumber ldaa randno; after this, divide random by 4 staa i staa countdown; divide by 4 here ldaa i staa enemyval,x; stores the enemyvalue i at position i in enemyval staa enemyrow,x; stores the new enemy position at row 1, position i in enemyrow ldaa randno; then make randno between 1-54 rts randomnumber ldaa #7 staa randno
a .byte 0; current value for redrawing enemyval y .byte 0; current value for redrawing enemyrow i .byte 0; variable for random numbers put into enemyrow and enemyval scrhigh .byte $FB ; high byte screen address scrlow .byte $00 ; low byte screen address rowcount .byte 20 ; number of rows to count countdown .byte 5 ;time till next enemy enemyval .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;array of enemy values enemyrow .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;array holding enemy row location randno .byte 0 count .byte 0 randcount .byte 0 updatecount .byte 0 screen .equ $FB00 pcaret .stw $FB00
I'm not here for a free homework solution, i genuinely want to learn this stuff to improve my (currently underdeveloped) skills as a programmer, i've programmed before in c++ java and also zscript (pseudocode for an online mud) but assembly is totally foreign to me. Any help would be greatly appreciated, I'll be checking in over the next day or so.
This is all being done on an emulator with a fixed size of 54X20 chars. Apologies for the messiness of the code, it's still a jumble while i work out what i'm doing.
Thanks in advance for any help.