0 Members and 1 Guest are viewing this topic.
.nolist#include "ti83plus.inc"#define ProgStart $9D95.list.org ProgStart - 2.db t2ByteTok, tAsmCmp B_CALL(_RunIndicOff) B_CALL(_GrBufClr)Show: CALL PutSpr B_CALL(_GrBufCpy)KeyLoop: LD A, $FD OUT (1), A IN A, (1) CP %10111111 RET Z LD A, $FE OUT (1), A IN A, (1) CP %11111110 JP Z, MoveDown CP %11111101 JP Z, MoveLeft CP %11110111 JP Z, MoveUp JR NZ, KeyLoop; Move sprite right CALL PutSpr ; Erase sprite LD HL, xpos INC (HL) JR Show ; Draw sprite at new locationMoveLeft:; Move sprite left CALL PutSpr LD HL, xpos DEC (HL) JR ShowMoveUp:; Move sprite up CALL PutSpr LD HL, ypos DEC (HL) JR ShowMoveDown: CALL PutSpr LD HL, ypos INC (HL) JR Showypos: .DB 0xpos: .DB 0sprite: .DB %10000001 .DB %11000011 .DB %01100110 .DB %00111100 .DB %00111100 .DB %01100110 .DB %11000011 .DB %10000001PutSpr: LD DE, (ypos) LD IX, sprite LD B, 8ClipSprXOR:; D = xpos; E = ypos; B = height; IX = image address; Start by doing vertical clipping LD A, %11111111 ; Reset clipping mask LD (clip_mask), A LD A, E ; If ypos is negative OR A ; try clipping the top JP M, ClipTop ; SUB 64 ; If ypos is >= 64 RET NC ; sprite is off-screen NEG ; If (64 - ypos) > height CP B ; don't need to clip JR NC, VertClipDone ; LD B, A ; Do bottom clipping by JR VertClipDone ; setting height to (64 - ypos)ClipTop: LD A, B ; If ypos <= -height NEG ; sprite is off-screen SUB E ; RET NC ; PUSH AF ADD A, B ; Get the number of clipped rows LD E, 0 ; Set ypos to 0 (top of screen) LD B, E ; Advance image data pointer LD C, A ; ADD IX, BC ; POP AF NEG ; Get the number of visible rows LD B, A ; and set as heightVertClipDone:; Now we're doing horizontal clipping LD C, 0 ; Reset correction factor LD A, D CP -7 ; If 0 > xpos >= -7 JR NC, ClipLeft ; clip the left side CP 96 ; If xpos >= 96 RET NC ; sprite is off-screen CP 89 ; If 0 <= xpos < 89 JR C, HorizClipDone ; don't need to clipClipRight: AND 7 ; Determine the clipping mask LD C, A LD A, %11111111FindRightMask: ADD A, A DEC C JR NZ, FindRightMask LD (clip_mask), A LD A, D JR HorizClipDoneClipLeft: AND 7 ; Determine the clipping mask LD C, A LD A, %11111111FindLeftMask: ADD A, A DEC C JR NZ, FindLeftMask CPL LD (clip_mask), A LD A, D ADD A, 96 ; Set xpos so sprite will "spill over" LD C, 12 ; Set correctionHorizClipDone:; A = xpos; E = ypos; B = height; IX = image address; Now we can finally display the sprite. LD H, 0 LD D, H LD L, E ADD HL, HL ADD HL, DE ADD HL, HL ADD HL, HL LD E, A SRL E SRL E SRL E ADD HL, DE LD DE, PlotSScreen ADD HL, DE LD D, 0 ; Correct graph buffer address LD E, C ; if clipping the left side SBC HL, DE ; AND 7 JR Z, _Aligned LD C, A LD DE, 11_RowLoop: PUSH BC LD B, C LD A, (clip_mask) ; Mask out the part of the sprite AND (IX) ; to be horizontally clipped LD C, 0_ShiftLoop: SRL A RR C DJNZ _ShiftLoop XOR (HL) LD (HL), A INC HL LD A, C XOR (HL) LD (HL), A ADD HL, DE INC IX POP BC DJNZ _RowLoop RET_Aligned: LD DE, 12_PutLoop: LD A, (IX) XOR (HL) LD (HL), A INC IX ADD HL, DE DJNZ _PutLoop RETclip_mask: .DB 0.end.end
cntr: .db 0
LD cntr, C
LD (cntr), C
.nolist#include "ti83plus.inc"#define ProgStart $9D95.list.org ProgStart - 2.db t2ByteTok, tAsmCmpypos: .DB 0xpos: .DB 0clip_mask: .DB 0 B_CALL(_RunIndicOff) B_CALL(_GrBufClr) LD C, $0001 PUSH BCShow: CALL PutSpr B_CALL(_GrBufCpy)KeyLoop: LD A, $FD OUT (1), A IN A, (1) CP %10111111 RET Z CP %11111101 JP Z, NextSpr CP %11111011 JP Z, PrevSpr LD A, $FE OUT (1), A IN A, (1) CP %11111110 JP Z, MoveDown CP %11111101 JP Z, MoveLeft CP %11110111 JP Z, MoveUp JR NZ, KeyLoop; Move sprite right CALL PutSpr ; Erase sprite LD HL, xpos INC (HL) JR Show ; Draw sprite at new locationMoveLeft:; Move sprite left CALL PutSpr LD HL, xpos DEC (HL) JR ShowMoveUp:; Move sprite up CALL PutSpr LD HL, ypos DEC (HL) JR ShowMoveDown: CALL PutSpr LD HL, ypos INC (HL) JR ShowNextSpr: POP BC LD A, C OR A RET Z CP 255 RET Z INC C CALL PutSprPrevSpr: POP BC LD A, C OR A RET Z CP 255 RET Z DEC C CALL PutSprPutSpr: PUSH BC LD DE, (ypos) LD A, C CP 1 LD IX, Spr1 CP 2 LD IX, Spr2 LD B, 8ClipSprXOR:; D = xpos; E = ypos; B = height; IX = image address; Start by doing vertical clipping LD A, %11111111 ; Reset clipping mask LD (clip_mask), A LD A, E ; If ypos is negative OR A ; try clipping the top JP M, ClipTop ; SUB 64 ; If ypos is >= 64 RET NC ; sprite is off-screen NEG ; If (64 - ypos) > height CP B ; don't need to clip JR NC, VertClipDone ; LD B, A ; Do bottom clipping by JR VertClipDone ; setting height to (64 - ypos)ClipTop: LD A, B ; If ypos <= -height NEG ; sprite is off-screen SUB E ; RET NC ; PUSH AF ADD A, B ; Get the number of clipped rows LD E, 0 ; Set ypos to 0 (top of screen) LD B, E ; Advance image data pointer LD C, A ; ADD IX, BC ; POP AF NEG ; Get the number of visible rows LD B, A ; and set as heightVertClipDone:; Now we're doing horizontal clipping LD C, 0 ; Reset correction factor LD A, D CP -7 ; If 0 > xpos >= -7 JR NC, ClipLeft ; clip the left side CP 96 ; If xpos >= 96 RET NC ; sprite is off-screen CP 89 ; If 0 <= xpos < 89 JR C, HorizClipDone ; don't need to clipClipRight: AND 7 ; Determine the clipping mask LD C, A LD A, %11111111FindRightMask: ADD A, A DEC C JR NZ, FindRightMask LD (clip_mask), A LD A, D JR HorizClipDoneClipLeft: AND 7 ; Determine the clipping mask LD C, A LD A, %11111111FindLeftMask: ADD A, A DEC C JR NZ, FindLeftMask CPL LD (clip_mask), A LD A, D ADD A, 96 ; Set xpos so sprite will "spill over" LD C, 12 ; Set correctionHorizClipDone:; A = xpos; E = ypos; B = height; IX = image address; Now we can finally display the sprite. LD H, 0 LD D, H LD L, E ADD HL, HL ADD HL, DE ADD HL, HL ADD HL, HL LD E, A SRL E SRL E SRL E ADD HL, DE LD DE, PlotSScreen ADD HL, DE LD D, 0 ; Correct graph buffer address LD E, C ; if clipping the left side SBC HL, DE ; AND 7 JR Z, _Aligned LD C, A LD DE, 11_RowLoop: PUSH BC LD B, C LD A, (clip_mask) ; Mask out the part of the sprite AND (IX) ; to be horizontally clipped LD C, 0_ShiftLoop: SRL A RR C DJNZ _ShiftLoop XOR (HL) LD (HL), A INC HL LD A, C XOR (HL) LD (HL), A ADD HL, DE INC IX POP BC DJNZ _RowLoop RET_Aligned: LD DE, 12_PutLoop: LD A, (IX) XOR (HL) LD (HL), A INC IX ADD HL, DE DJNZ _PutLoop RETSpr1: .DB %10000001 .DB %11000011 .DB %01100110 .DB %00111100 .DB %00111100 .DB %01100110 .DB %11000011 .DB %10000001Spr2: .DB %11111111 .DB %10000001 .DB %10000001 .DB %10000001 .DB %10000001 .DB %10000001 .DB %10000001 .DB %11111111.end.end
P.s. I know C is already used elsewere, that is likely to screw it up but i tried to insert a cntr byte by doing:Code: [Select]cntr: .db 0but then every time I did this:Code: [Select]LD cntr, Cor thisCode: [Select]LD (cntr), Cit threw a error saying: "unrecognized argument"