Hello all, this code isn't doing anything right, here it is, in case you know what's wrong xD
Known issues:
Wrong colors
Box is stretched out (wide)
Doesn't end on pressing mode, I'd assume because the loop continues to execute, but I dunno at this point
Screenshot:
Code: .nolist
#include "includes\ti84pce.inc"
.list
.assume ADL=1
.org userMem-2
.db tExtTok,tAsm84CeCmp
_ClearVRAM equ 000374h
pixelX equ cmdpixelshadow
pixelY equ pixelX+3
ld hl,12
ld (pixelX),hl
ld a,12
ld (pixelY),a
call _RunIndicOff
call _clearVRAM
ld a,lcdbpp8
ld (mpLcdCtrl),a
call drawFrame
create1555Palette:
ld hl,mpLcdPalette ; MMIO address of LCD Palette
ld b,0
_cp1555Loop:
ld d,b
ld a,b
and a,%11000000
srl d
rra
ld e,a
ld a,%00011111
and a,b
or a,e
ld (hl),a
inc hl
ld (hl),d
inc hl
inc b
jr nz,_cp1555Loop
drawFrame:
call _GetCSC
cp skUp
call z,upPressed
cp skDown
call z,downPressed
cp skLeft
call z,leftPressed
cp skRight
call z,rightPressed
cp skMode
call z,endGame
ret z
call renderFrame
jr drawFrame
endGame:
call _clearVRAM
ld a,lcdbpp16
ld (mpLcdCtrl),a
call _DrawStatusBar
ei
ret
downPressed:
ld hl,(pixelY)
ld DE,8
ADD HL,DE
ld (pixelY),HL
call _clearVRAM
ret
upPressed:
ld hl,(pixelY)
ld DE,8
SBC HL,DE
ld (pixelY),HL
call _clearVRAM
ret
leftPressed:
ld hl,(pixelX)
ld DE,8
SBC HL,DE
ld (pixelX),HL
call _clearVRAM
ret
rightPressed:
ld hl,(pixelX)
ld DE,8
ADD HL,DE
ld (pixelX),HL
call _clearVRAM
ret
renderFrame:
ld hl,Sprite_sprite
ld a,(pixelX)
ld B,A
ld a,(pixelY)
ld C,A
call drawSprite8bpp
ret
;--------------------------------------------------------------
; drawSprite8bpp
; 8bpp sprite drawn to screen
; b,c = x,y
; hl -> sprite
;--------------------------------------------------------------
drawSprite8bpp:
ld de,SaveW8bpp+1 ; Width
call setSpriteBoundary
push ix
pop hl
drawLoopLineNext8bpp:
push bc
push de
SaveW8bpp:
ld b,0
drawLoopLine8bpp:
ld a,(hl)
ld (de),a
inc de
ld (de),a
inc de
inc hl
djnz drawLoopLine8bpp
ex de,hl ; de = hl
pop hl
ld bc,160*2
add hl,bc
ex de,hl
pop bc
djnz drawLoopLineNext8bpp
ret
setSpriteBoundary:
ld a,(hl) ; a = w, b = h
push af
inc hl
ld a,(hl)
ld (de),a ; Width
inc hl ; hl->data
push hl
ld hl,0
ld l,b
ld a,c
add hl,hl ; b*2
add hl,hl ; b*4
push hl ; Save X
ld de,160*2
inc a
ld b,8
ld hl,0
add hl,hl
rlca
jr nc,$+3
add hl,de
djnz $-5
ld de,vRam-(160*2)
add hl,de
pop de ; de=X
add hl,de ; Add X
ex de,hl ; de->place to draw
pop ix
pop bc
ret
#include "sprite.bin"
And sprite.bin:
Code: Sprite_paletteStart:
.dw $8000 ; 0
.dw $fc00 ; 1
Sprite_paletteEnd:
Sprite_sprite:
.db $10,$10 ; width, height
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$1,$1,$0,$0,$0
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
.db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0