I posted about this a bit on Outside the Box Programming, but I thought that I'd post the code here. Note that this is my first ASM game and I have changed a few parts of this code:


Code:

:DEFHDR.HDR
:LD HL,0
:LD (9872H),HL
:BCALL RUNINDICOFF
:RES 5,(IY)
:BCALL CLRLCDFULL
:LD A,0
:LD DE,PLOTSSCREEN
:CLR:
:LD BC,12
:LD H,D
:LD L,E
:ADD HL,BC
:LD D,H
:LD E,L
:LD HL,CL
:PUSH AF
:PUSH DE
:LDIR
:BCALL GRBUFCPY
:POP DE
:POP AF
:INC A
:CP 63
:JP NZ,CLR
:MOVE:
:HALT
:HALT
:HALT
:LD A,(9873H)
:INC A
:LD (9873H),A
:CP 0
:CALL Z,MO2
:LD A,(DIR)
:OR A
:JP Z,MUP
:CP 1
:JP Z,MLEFT
:CP 2
:JP Z,MDOWN
:LD A,(XPOS)
:CP 94
:JP Z,END
:INC A
:LD (XPOS),A
:JP DRAW
:MO2:
:LD A,(9872H)
:INC A
:LD (9872H),A
:RET
:MUP:
:LD A,(YPOS)
:OR 0
:JP Z,END
:DEC A
:LD (YPOS),A
:JP DRAW
:MLEFT:
:LD A,(XPOS)
:OR A
:JP Z,END
:DEC A
:LD (XPOS),A
:JP DRAW
:MDOWN:
:LD A,(YPOS)
:CP 62
:JP Z,END
:INC A
:LD (YPOS),A
:DRAW:
:LD A,(XPOS)
:LD B,A
:LD A,(YPOS)
:LD C,A
:LD D,3
:BCALL IPOINT
:JR NZ,END
:LD A,(XPOS)
:LD B,A
:LD A,(YPOS)
:LD C,A
:LD D,1
:BCALL IPOINT
:KEY:
:LD A,FFH
:OUT (1),A
:LD A,11111110B
:OUT (1),A
:IN A,(1)
:BIT 0,A
:JP Z,UP
:BIT 1,A
:JP Z,LEFT
:BIT 2,A
:JP Z,RIGHT
:BIT 3,A
:JP Z,DOWN
:JP MOVE
:DOWN:
:LD A,2
:LD (DIR),A
:JP MOVE
:LEFT:
:LD A,1
:LD (DIR),A
:JP MOVE
:RIGHT:
:LD A,3
:LD (DIR),A
:JP MOVE
:UP:
:LD A,0
:LD (DIR),A
:JP MOVE
:END:
:BCALL CLRSCRNFULL
:BCALL HOMEUP
:LD HL,TXT
:BCALL PUTS
:LD A,(9872H)
:LD H,A
:LD A,(9873H)
:LD L,A
:BCALL DISPHL
:END2:
:BCALL GETKEY
:CP 5
:JP NZ,END2
:BCALL CLRSCRNFULL
:BCALL HOMEUP
:RET
:DIR:
:.DB 0
:XPOS:
:.DB 48
:YPOS:
:.DB 32
:TXT:
:.DB "Your Score:     ",0
:CL:
:.DB 0,0,0,0,0,0,0,0,0,0,0,0


I changed the routine that clears the buffer (twice, actually), but I was still wondering how the rest is (I have not added the music part yet; it will be in place of the HALTs, most likely).

Thanks for any advice!

Sorry for the lack of comments, but I programmed this oncalc, where space is limited.

All coding and tables ©2004-2007 Kerm Martian
Without changing the structure of the code:

Code:
:DEFHDR.HDR
:LD HL,0
:LD (9872H),HL
:BCALL RUNINDICOFF
:RES 5,(IY)
:BCALL CLRLCDFULL
:XOR A
:LD DE,PLOTSSCREEN
:CLR:
:LD HL,0
:ADD HL,BC
:ADD HL,DE
:LD D,H
:LD E,L
:LD HL,CL
:PUSH AF
:PUSH DE
:LDIR
:BCALL GRBUFCPY
:POP DE
:POP AF
:CP 62
:JP NZ,CLR
:MOVE:
:NOP
:NOP
:NOP
:LD HL,9873H
:INC (HL)
:CALL Z,MO2
:LD A,(DIR)
:OR A
:JP Z,MUP
:CP 1
:JP Z,MLEFT
:CP 2
:JP Z,MDOWN
:LD A,(XPOS)
:CP 94
:JP Z,END
:INC A
:LD (XPOS),A
:JP DRAW
:MO2:
:LD HL,9872H
:INC (HL)
:RET
:MUP:
:LD A,(YPOS)
:OR A
:JP Z,END
:DEC A
:LD (YPOS),A
:JP DRAW
:MLEFT:
:LD A,(XPOS)
:OR A
:JP Z,END
:DEC A
:LD (XPOS),A
:JP DRAW
:MDOWN:
:LD A,(YPOS)
:CP 62
:JP Z,END
:INC A
:LD (YPOS),A
:DRAW:
:LD A,(XPOS)
:LD B,A
:LD A,(YPOS)
:LD C,A
:LD D,3
:BCALL IPOINT
:JR NZ,END
:LD A,(XPOS)
:LD B,A
:LD A,(YPOS)
:LD C,A
:LD D,1
:BCALL IPOINT
:KEY:
:LD A,FFH
:OUT (1),A
:LD A,11111110B
:OUT (1),A
:IN A,(1)
:BIT 0,A
:JP Z,UP
:BIT 1,A
:JP Z,LEFT
:BIT 2,A
:JP Z,RIGHT
:BIT 3,A
:JP Z,DOWN
:JP MOVE
:DOWN:
:LD A,2
:LD (DIR),A
:JP MOVE
:LEFT:
:LD A,1
:LD (DIR),A
:JP MOVE
:RIGHT:
:LD A,3
:LD (DIR),A
:JP MOVE
:UP:
:XOR A
:LD (DIR),A
:JP MOVE
:END:
:BCALL CLRSCRNFULL
:BCALL HOMEUP
:LD HL,TXT
:BCALL PUTS
:LD HL,(9872H)
:BCALL DISPHL
:END2:
:BCALL GETKEY
:CP 5
:JP NZ,END2
:BCALL CLRSCRNFULL
:BCALL HOMEUP
:RET
:DIR:
:NOP
:YPOS:
:.DB 32
:XPOS:
:.DB 48
:TXT:
:.DB "Your Score:     ",0
:CL:
:.DB 0,0,0,0,0,0,0,0,0,0,0,0


I hope that works... I wasn't able to test it, but I was trying to be conservative in my modifications. I know you plan on removing them, but why are you using HALTs to fill up empty space? They're just relying on the calc's operations to interrupt them. NOP is your friend. Smile
Yeah, but nop takes a microsecond or so, while halt takes an appreciable fraction of a second. nop outside of a huge loop doesn't do any noticeable slowing.

Gah, that ASM is impossible to read in unicolumnar form. Razz
You mean monocolumnar. Unicolumnar is zygocolumnar. Razz

Gosh, with my projects, opcodes make for much faster coding, but debugging sucks.
Do I mean monocolumnar? Unicolumnar sounds more correct to my ears, but w/e. Laughing I can imagine that debugging must be horrible. Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement