;############## CMonster by Patrick Davidson - level loading Load_Level: add a,a add a,a add a,a add a,a ; A = level number * 16 #ifdef TI84CE ld de,0 #else ld d,0 #endif ld e,a ld hl,levelData-48 add hl,de ; add 48 * level number add hl,de add hl,de ld de,map ld bc,48 ldir ; copy original map ret Draw_Map: ld de,12345 xor a ld b,a bizarre_board: push de push af push bc call Draw_Brick pop bc pop af pop de inc d inc e inc a cp 16 jr nz,bizarre_board inc b ld a,20 cp b jp z,Clear_Below_Tiles xor a jr bizarre_board ;############## Find brick address and mask ; Input B = brick X coordinate (0-19) ; Input A = brick Y coordinate (0-15) ; Output HL -> brick memory location ; Output A = brick b it mask Find_Brick: ld d,b ; D = brick X coordinate ld e,a ; E = brick Y coordinate Find_Brick_DE: ld a,d and 7 ld hl,bit_masks #ifdef TI84CE ld bc,0 #else ld b,0 ; BC = bits into current byte #endif ld c,a add hl,bc ; HL -> position in bit mask table ld a,d rra rra rra ; A = bytes into row and 7 add a,e add a,e add a,e ; A = bytes into row + 3 * double row number #ifdef TI84CE ld de,0 #else ld d,0 ; DE = bytes into map #endif ld e,a ld a,(hl) ld hl,map add hl,de ret bit_masks: .db 128,64,32,16,8,4,2,1