Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DrawCell: ; Draws cell at x=b, y=c, color=A; destroys AF, HL, DE
- push bc
- push af
- dec b
- dec c
- or a
- sbc hl,hl
- ld l,b
- call HLMult8
- inc hl
- push hl
- pop de ; end of X
- ld a,c
- call AMult8
- inc a
- ld l,a ; end of Y
- pop af
- ld h,CellSize-2 ; height
- ld bc,CellSize-2 ; width
- push de
- push hl
- call FillRect
- pop hl
- pop de
- pop bc
- ret
- RedrawCell:
- call GetCell
- ld a,(hl)
- cp OnCellData
- call z,LdOnColor
- call nz,LdOffColor
- jp DrawCell
- DrawCursor:
- push bc
- call GetCell
- ld a,(hl)
- cp OnCellData
- call z,LdOnColor
- call nz,LdOffColor
- push af
- ld a,CursorColor
- call DrawCell
- pop af
- inc de ; X
- inc l ; Y
- ld bc,CellSize-4 ; Width
- dec h
- dec h
- call FillRect
- pop bc
- xor a ; Prevents accidental "keypresses"
- ret
- LdOnColor:
- ld a,OnCellColor
- ret
- LdOffColor:
- ld a,OffCellColor
- ret
- RenderBoard:
- ld hl,Board+BoardSize
- ld b,Rows
- RenderRowLoop:
- push bc
- ld c,b
- ld b,Cols
- RenderColLoop:
- push bc
- dec hl
- push hl
- call RedrawCell
- pop hl
- pop bc
- djnz RenderColLoop
- pop bc
- djnz RenderRowLoop
- ret
- FillRect: ; A=color, BC=width, DE=x, H=height, L=y
- ld (FillRect_Color),a
- ld a,h
- ld h,160
- mlt hl
- add hl,hl
- add hl,de
- ld de,vRam
- add hl,de
- dec bc
- FillRect_Loop:
- FillRect_Color = $+1
- ld (hl),0
- push hl
- pop de
- inc de
- push bc
- ldir
- pop bc
- ld de,lcdWidth
- add hl,de
- sbc hl,bc
- dec a
- jr nz,FillRect_Loop
- ret
- Setup8bppMode:
- ld a,lcdBpp8
- ld (mpLcdCtrl),a
- ret
- LoadxLIBCPalette:
- ld de,mpLcdPalette
- ld b,l
- LoadxLIBCPalette_Loop:
- ld a,b
- rrca
- xor b
- and %11100000
- xor b
- ld (de),a
- inc de
- ld a,b
- rra
- ld (de),a
- inc de
- inc b
- jr nz,LoadxLIBCPalette_Loop
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement