; ************** SandBox level set for Orzunoid ************************** .org 0 .include "usgard.h" .include "orzunoid.h" .db "Tartarus 1.0 for Orz6+" .db 0 ; ************** Level's Data ******************************************** gs_flag =DELC_LEN+1 ; Set when grayscale active gs_vbl =DELC_LEN+2 ; Grayscale frame (0, 1, 2) f_group =DELC_LEN+3 ; Frame group (0 = first frame, 2 = all others) o_pw =DELC_LEN+4 ; Old paddle width bip =DELC_LEN+5 ; ************** Initialization code ************************************* ld de,TEXT_MEM2 ; Load universe file data ld bc,14 ld hl,&data_block ldir ld hl,&Orzunoid_Name ; Run Orzunoid call VAR_EXEC ld hl,0 ; Erase the signature word ld (u_signature_52682),hl ld a,3 ld (USG_BITS),a ret ; ************** Initialization data ************************************* Orzunoid_Name: .db "Orzunoid",0 ; Name of program to run data_block: .dw 52682 ; Signature word R_u_call =$-1 .dw universe_setup ; Level setup routine .db "Tartarus",0 ; Name of the universe .db 0 ; Version of the universe ; ************** Level setup routine ************************************* universe_setup: ld hl,&extract_level ; Replace extract_level vector ld (__extract_level+1),hl ld hl,&test_hit ; Replace test_hit vector ld (__test_hit+1),hl ld hl,(__play_level+1) ; Back-up play_level vector ld (&smc_play_level+1),hl ld hl,&draw_level ; Replace draw_level vector ld (__draw_level+1),hl ld hl,(__exit_game+1) ; Back-up exit_game vector ld (&smc_exit_game+1),hl ld hl,&exit_game ; Replace exit_game vector ld (__exit_game+1),hl ld hl,(__paddle_move+1) ; Back-up paddle_move vector ld (&smc_paddle_move+1),hl ld hl,&paddle_move ; Replace paddle_move vector ld (__paddle_move+1),hl ld hl,&play_level ; Replace play_level vector ld (__play_level+1),hl ld hl,&title_screen ; Replace title_screen vector ld (__title_screen+1),hl ld hl,&display_screen ; Replace display_screen vector ld (__display_screen+1),hl ld a,6 ; Set # of levels to 6 ld (num_levels),a ld hl,(__ballstuff+1) ; Really ugly hack to change loop_find_position: ; the balls's image by locating dec hl ; the orignial n the Orzunoid push hl ; code and modifying that call LD_HL_MHL ld de,$303 call CP_HL_DE pop hl jr nz,loop_find_position ld (bip),hl inc hl inc hl ld (hl),%11100000 inc hl inc hl ld (hl),%11100000 ret ; ************** New game screen display routine ************************* display_screen: ld hl,gs_vbl ld a,2 vwait: cp (hl) jr nz,vwait ld de,$fc80 ld hl,GRAPH_MEM ld bc,896 ldir ld (f_group),a ret ; ************** New main in-game loop *********************************** play_level: call &grayscale_init ; Set up grayscale ld hl,gs_flag ld (hl),0 jp c,__exit_game ld (hl),1 ld hl,(PAGE2ADDR) ; Render LS plane in buffer ld bc,1023 call OTH_CLEAR ld ix,(PAGE2ADDR) ld de,128 add ix,de ld hl,data ld b,5 s_outer: push bc ld b,16 s_inner: ld a,(hl) dec a jr z,draw_block_ dec a JR Z,draw_block_tough_ dec a jr z,draw_block_solid_ ok2: inc hl inc ix djnz s_inner ld de,112 add ix,de pop bc djnz s_outer xor a ;Clear f_group ld (f_group),a smc_play_level: ;Play da game! call $0000 deactivate_grayscale: ;De-activate grayscale ld a,(gs_flag) or a ret z call INT_REMOVE ld a,$3c out (0),a xor a ld (gs_flag),a ret draw_block_: ;Draw a standard block ld (ix+000),%11111111 ld (ix+016),%10000000 ld (ix+032),%10000000 ld (ix+048),%10000000 ld (ix+064),%10000000 ld (ix+080),%10000000 ld (ix+096),%10000000 ld (ix+112),%10000000 jr ok2 draw_block_solid_: ;Draw a solid block ld (ix+000),%11111111 ld (ix+016),%11111111 ld (ix+032),%11011101 ld (ix+048),%11111111 ld (ix+064),%11111111 ld (ix+080),%11111111 ld (ix+096),%11011101 ld (ix+112),%11111111 jr ok2 draw_block_tough_: ;Draw a tough block cpl ld (ix+000),%11111111 ld (ix+016),%11111111 ld (ix+032),%11111111 ld (ix+048),%11111111 ld (ix+064),%11111111 ld (ix+080),%11111111 ld (ix+096),%11111111 ld (ix+112),%11111111 jp &ok2 ; ************** New level drawing code ********************************** draw_level: ld hl,GRAPH_MEM ;Clear display memory ld b,110 xor a clgloop: ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl djnz clgloop ld a,(guard) ld b,16 dbloop: ld (hl),a inc hl djnz dbloop ld hl,won ;Redraw all bricks ld (hl),0 ld ix,GRAPH_MEM ld hl,data ld b,5 rs_outer:push bc ld b,16 rs_inner:ld a,(hl) dec a jr z,draw_block dec a JR Z,draw_block_tough dec a jr z,draw_block_solid ok: inc hl inc ix djnz rs_inner ld de,112 add ix,de pop bc djnz rs_outer ret draw_block: ;Draw a standard block cpl ld (won),a ld (ix+016),%01111111 ld (ix+032),%01111111 ld (ix+048),%01111111 ld (ix+064),%01111111 ld (ix+080),%01111111 ld (ix+096),%01111111 ld (ix+112),%01111111 jr ok draw_block_solid: ;Draw a solid block ld (ix+000),%11111111 ld (ix+016),%10111011 ld (ix+032),%11111111 ld (ix+048),%11111111 ld (ix+064),%11111111 ld (ix+080),%10111011 ld (ix+096),%11111111 ld (ix+112),%11111111 jr ok draw_block_tough: ;Draw a tough block cpl ld (won),a ld (ix+016),%01111111 ld (ix+032),%01111111 ld (ix+048),%01111111 ld (ix+064),%01111111 ld (ix+080),%01111111 ld (ix+096),%01111111 ld (ix+112),%01111111 jr ok ; ************** New Ball Handling Code ********************************** spr_ball:.db 3,3 .db %01000000 .db %11100000 .db %01000000 ; ************** New Paddle Movement Code ******************************** paddle_move: ; ld a,$7e ; halt ; out (1),a ; ld a,(f_group) ; or a ; ld hl,o_pw ; call nz,&paddle_render ; in a,(1) ; rrca smc_paddle_move: call $0000 ld hl,(PAGE2ADDR) ;Comment out for XOR-version ld bc,960 ; add hl,bc ; ld bc,64 ; call OTH_CLEAR ; ld hl,p_width paddle_render: ld e,60 ld a,(p) srl a ld d,a ld ix,&paddlen ld a,(hl) ld (o_pw),a cp 32 jp z,&drw_sprw ld ix,&paddlew halt ; jp &drw_sprw paddlen: .db 16,4 .db %01111111,%11111110 .db %11111111,%11111111 .db %11111111,%11111111 .db %01111111,%11111110 paddlew: .db 32,4 .db %01111111,%11111111,%11111111,%11111110 .db %11111111,%11111111,%11111111,%11111111 .db %11111111,%11111111,%11111111,%11111111 .db %01111111,%11111111,%11111111,%11111110 ; ************** Sprite rendering routine ******************************** offsets_table: .db 128,64,32,16,8,4,2,1 drw_sprw:ld a,d and 7 ld hl,&offsets_table ld c,a ld b,0 add hl,bc ld a,(hl) ld (&wsmc1+1),a ld (&wsmc2+1),a ld hl,(PAGE2ADDR) ;Calculate byte number ld a,e add a,a add a,a add a,a rl b add a,a rl b ld c,d srl c srl c srl c or c ld c,a add hl,bc ld d,(ix) ld b,(ix+1) woloop: push bc ;Save # of rows push hl ;Save screen address ld b,d ;Load width ld c,(ix+2) ;Load one line of image inc ix wsmc1 ld a,1 ;Load pixel mask wiloop: sla c ;Test leftmost pixel jr nc,wnoplot ;See if a plot is needed ld e,a ;XOR pixel with screen xor (hl) ld (hl),a ld a,e wnoplot: rrca jr nc,wnotedge ;Test if edge of byte reached inc hl ;Go to next byte wnotedge wsmc2: cp 1 jr z,wover_1 djnz wiloop pop hl ;Restore address ld bc,16 ;Go to next line add hl,bc pop bc ;Restore data djnz woloop ret wover_1: ld c,(ix+2) inc ix djnz wiloop dec ix pop hl ld bc,16 add hl,bc pop bc djnz woloop ret ; ************** New level loader routine ******************************** extract_level: ld hl,&universe_data-20 ld de,20 inc a ld b,a loop_calc_lptr: add hl,de djnz loop_calc_lptr ld b,20 ;Copy the map ld de,data set_up_1: push bc ld b,4 ld c,(hl) loop_row: rlc c rlc c ld a,c and 3 ld (de),a inc de djnz loop_row inc hl pop bc djnz set_up_1 ret universe_data: .db %00000000,%00000000,%00000000,%00000000 .db %00101010,%10101010,%10101010,%10101000 .db %00010101,%01010101,%01010101,%01010100 .db %00000000,%00000000,%00000000,%00000000 .db %00000000,%00000000,%00000000,%00000000 .db %11111111,%11111111,%11111111,%11111111 .db %11000000,%00000000,%00000000,%00000011 .db %11000010,%10101010,%10101010,%10000011 .db %11000001,%01010101,%01010101,%01000011 .db %11000010,%10101010,%10101010,%10000011 .db %00000000,%00000000,%00000000,%00000000 .db %00001010,%10101010,%10101010,%10101000 .db %01010000,%00000000,%00000000,%00000101 .db %01011111,%11111111,%11111111,%11110101 .db %01010101,%01010101,%01010101,%01010101 .db %10101010,%10101010,%10101010,%10101010 .db %10000000,%00000000,%00000000,%00000010 .db %10000011,%11111111,%11111111,%11000010 .db %10000001,%01010101,%01010101,%01000010 .db %10000001,%01010101,%01010101,%01000010 .db %10010101,%01010101,%01010101,%01010110 .db %10010101,%01010101,%01010101,%01010110 .db %10010101,%11111111,%11111111,%01010110 .db %10010101,%01010101,%01010101,%01010110 .db %10101010,%10101010,%10101010,%10101010 .db %01100110,%01100110,%01100110,%01100110 .db %10011001,%10011001,%10011001,%10011001 .db %01100110,%01100110,%01100110,%01100110 .db %10011001,%10011001,%10011001,%10011001 .db %01100110,%01100110,%01100110,%01100110 ; ************** New exit routine **************************************** exit_game: call &deactivate_grayscale ld hl,(bip) ;Undo ball image hack inc hl inc hl ld (hl),%01000000 inc hl inc hl ld (hl),%01000000 smc_exit_game: jp $0000 ; ************** New title screen **************************************** title_screen: ld hl,contrst ;Decrease contrast 1 step ld a,(hl) dec a ld (hl),a out (2),a call CLEARLCD ;Display messages ld ($800c),de ld hl,&title_message ld ix,CURSOR_ROW call D_ZT_STR inc (ix) call D_ZT_STR inc (ix) call D_ZT_STR call OTH_PAUSE xor a ret title_message: .db "Welcome to Tartarus!!",0 .db " Copyright 1998-1999 " .db " by Patrick Davidson " .db " All Rights Reserved ",0 .db "[ENTER] if you dare..",0 ; ************** New hit testing routine ********************************* test_hit: ld a,(hl) ld e,a cp 39 jp p,&bottom_half ;Can't hit anything if below 39 and 56 ;A = row * 8 add a,a ld b,a ;B = row * 16 dec hl dec hl ld a,(hl) ;A = X coord and 240 ;A = column ld d,a rrca rrca rrca rrca and 15 ;A = column / 16 or b ;A = column / 16 + row * 4 ld l,a ld h,$81 ld a,(hl) ;A = brick type dec a jr z,hit_1 dec a jr z,hit_2 dec a jr z,hit_3 bottom_half: scf ccf ret hit_1: push de push hl call &get_brick_display_addr ld b,8 loop_erase_brick: ld (hl),0 add hl,de djnz loop_erase_brick pop hl pop de ld (hl),a ld hl,(score) ld a,(incr) add a,2 ld (incr),a ld c,a ld b,0 add hl,bc ld (score),hl ld hl,bonust ld a,(hl) or a scf ret nz ld a,r rrca ret c and 3 inc a ld b,a ld a,d rla jr c,abcdef ld (hl),b inc hl ld (hl),d jr common71 abcdef: inc b inc b inc b ld (hl),b inc hl ld a,d sub 8 ld (hl),a common71:inc hl ld (hl),e dec hl dec hl scf ret hit_2: push hl call &get_brick_display_addr ld b,7 add hl,de loop_dec_brick: ld (hl),128 add hl,de djnz loop_dec_brick pop hl ld (hl),1 ld hl,(score) inc hl inc hl ld (score),hl hit_3: scf ret get_brick_display_addr: ld a,l and 15 ld c,a ; B = Brick column ld h,0 ld a,l and 240 ; A = Brick row * 16 add a,16 add a,a ld l,a add hl,hl add hl,hl ld b,0 add hl,bc ld bc,(PAGE2ADDR) add hl,bc ld de,16 ret ; ************** Grayscale routines ************************************** grayscale_init: ld hl,(VAT_END) ; Locate grayscale page ld de,-1024 add hl,de ld l,0 ld de,(FIRST_FREE) call CP_HL_DE ret c ld (PAGE2ADDR),hl ld a,h and $3f ld (&smc_port_out+1),a xor a ld (gs_vbl),a ld hl,gs_vbl ld (hl),0 ld hl,&grayscale_int jp INT_INSTALL grayscale_int: ld hl,gs_vbl ld a,(hl) inc a ld (hl),a cp 3 jr z,first_page cp 2 ret nz smc_port_out: ld a,$00 out (0),a ret first_page: ld (hl),0 ld a,$3c out (0),a ret .end