diff --git a/src/bios/0module.mk b/src/bios/0module.mk new file mode 100644 index 0000000..91b4c11 --- /dev/null +++ b/src/bios/0module.mk @@ -0,0 +1,20 @@ + +BIOS_NAME := bios +BIOS_SRC := $(PATH_SRC)/$(BIOS_NAME) +BIOS_BIN := $(PATH_BIN)/$(BIOS_NAME) +BIOS_HEX := $(BIOS_BIN)/$(BIOS_NAME).hex +BIOS_DAT := $(BIOS_BIN)/$(BIOS_NAME).dat +BIOS_RELS := $(BIOS_BIN)/$(BIOS_NAME).rel +BIOS_CODE := $(BIOS_SRC)/$(BIOS_NAME).asm + +$(BIOS_BIN): + $(call mod_mkdir,$(BIOS_BIN)) + +$(BIOS_BIN)/%.rel: $(BIOS_SRC)/%.asm | $(BIOS_BIN) + $(call mod_compile_asm,$@,$<) + +$(BIOS_HEX): $(BIOS_RELS) + $(call mod_link_asm_dos,$(BIOS_HEX),$(BIOS_RELS)) + +$(BIOS_DAT): $(BIOS_HEX) + $(call mod_hex2dat,$(BIOS_HEX),$(BIOS_DAT)) diff --git a/src/bios/bios.asm b/src/bios/bios.asm new file mode 100644 index 0000000..762a44e --- /dev/null +++ b/src/bios/bios.asm @@ -0,0 +1,1697 @@ +; +; DOME SYSTEM BIOS +; + +DOS .equ 0x0005 +D_OPEN .equ 0x0F +D_SETDMA .equ 0x1A +D_READ .equ 0x27 +D_CLOSE .equ 0x10 +ENASLT .equ 0x24 + + +CHIPS .equ TAB_LOC-13 + ; CHIPS + ; 0b00000000 + ; 1 = FMPAC + ; 11 = MUS / 256 KB YES/NO + ; 1 = MOONSOUND + ; 1 = MSX-MIDI + ; 1 = FAC-MIDI + ; 1 = + ; 1 = +INT_ON .equ TAB_LOC-12 ; 0=AAN + +SPRATR .equ TAB_LOC-11 +MOUSEY .equ TAB_LOC-11 +MOUSEX .equ TAB_LOC-10 +MOUSE_OFF .equ TAB_LOC-9 ; AAN OF UIT +MOUSE_USE .equ TAB_LOC-8 ; " """""""" +MOUSE_PORT .equ TAB_LOC-7 ; PORT 1 OF 2 +MOUSE_WAIT1 .equ TAB_LOC-6 ; WAIT CYCLE 1 +MOUSE_WAIT2 .equ TAB_LOC-5 ; WAIT CYCLE 2 +MOUSE_BUTTONS .equ TAB_LOC-4 + +MSX_TYPE .equ TAB_LOC-3 +DOSJMPTAB .equ TAB_LOC-2 + +TAB_LOC .equ 0x0F00 +DOME_BIOS .equ 0x0F00 ; BIOS+GAMECODE(0x2500)+TANKTAB(0x3000) +DOME_VELD .equ 0x0F02 ; THE LEVEL(0x4000) +DOME_CODE .equ 0x0F04 ; THE DOME ENGINE(0x8000) +DOME_PAGE3 .equ 0x0F06 ; MORE ENGINE +DOME_MENU .equ 0x0F08 ; GFX DOME MENU+CODE(0x8000) +DOME_TEMP .equ 0x0F0A ; + +DOME_CH_CODE .equ 0x0F0C ; LEVEL CHOOSER CODE +DOME_CH_GFX1 .equ 0x0F0E ; LEVEL CHOOSE GFX +DOME_CH_GFX2 .equ 0x0F10 ; GFX + +DOME_MENT_CODE .equ 0x0F12 ; CODE VOOR MENTAT +DOME_MENT1 .equ 0x0F14 ; BUFFER VOOR GFX MENTAT + +DOME_GFX_UNIT .equ 0x0F16 ; GAME GFX (UNIT) +DOME_GFX_BLPA .equ 0x0F18 ; GAME GFX (BALK EN PAGE) + +DOME_MMENU .equ 0x0F1A ; MAIN MENU GFX + CODE AT 4000 + + ; org 0x0100 +.area _CODE + +ST: +C_01: JP GET_INT ;0x0100 +C_02: JP PUT_INT ;0x0103 +C_03: JP COLOR_WHITE ;0x0106 +C_04: JP COLOR_BLACK ;0x0109 +C_05: JP SCREEN_ON ;0x010C +C_06: JP SCREEN_OFF ;0x010F +C_07: JP SET_SCREEN0 ;0x0112 +C_08: JP SET_SCREEN5 ;0x0115 +C_09: JP SPRITES_ON ;0x0118 +C_10: JP SPRITES_OFF ;0x011B +C_11: JP PUT_SPRITE ;0x011E +C_12: JP SET_PAGE ;0x0121 +C_13: JP GET_TIME ;0x0124 +C_14: JP PUT_TXT ;0x0127 +C_15: JP PUT_TXT2 ;0x012A +C_16: JP INIT_BIOS ;0x012D +C_17: JP EXIT_ON_ERR ;0x0130 +C_18: JP LOAD ;0x0133 +C_19: JP INIT_LIB ;0x0136 +C_20: JP SAVE ;0x0139 +C_21: JP PUT_PAGE_FD ;0x013C +C_22: JP PUT_PAGE_FE ;0x013F + +C_23: JP M_MUSLOAD ;0x0142 +C_24: JP M_KITLOAD ;0x0145 +C_25: JP M_PLAY ;0x0148 +C_26: JP M_STOP ;0x014B +C_27: JP M_CONT ;0x014E +C_28: JP M_FADE ;0x0151 +C_29: JP M_LOC ;0x0154 +C_30: JP M_FREE ;0x0157 + +C_31: JP POP_UP_START ;0x015A +C_32: JP PUTBLK ;0x015D +C_33: JP PUT_COLOR ;0x0160 +C_34: JP DOME_MENU_CALL ;0x0163 +C_35: JP RESTORE_MEM ;0x0166 +C_36: JP INIT_BIOS_MEM ;0x0169 +C_37: JP RUN_GAME ;0x016C +C_38: JP INT_ROUTINE ;0x016F +C_39: JP HOOK_ON ;0x0172 +C_40: JP HOOK_OFF ;0x0175 +C_41: JP INIT_INT ;0x0178 + +C_42: JP M_MUSINFO ;0x017B +C_43: JP M_ADR ;0x017E +C_44: JP M_DRVINFO ;0x0181 +C_45: JP M_DATA ;0x0184 +C_46: JP DOSJMP ;0x0187 + +; clear data until ~DOME_MMENU=0x0F1A +;.ds 0x1000 + +INIT_BIOS: + ld e,#"2" + ld c,#0x02 + call 5 + DI + + POP DE ; CALL ENTRY WEG !!! + LD (ST_STACK),SP + PUSH DE + + LD HL,#INT_DOS + CALL GET_INT + + CALL CHECK_IF_INST + JR NZ,INIT_BIOS_CONT ; NO MOONSOUND + + LD A,(CHIPS) + SET 3,A + LD (CHIPS),A ; SET MOON SOUND + + xor a + ld de,#4*256+2 ;D=4 E=2 + call 0xFFCA + LD (DOSJMPTAB),HL + ld a,c + ld bc,#0x0C + add hl,bc + ld de,#CALL_SEG_INIT + ld bc,#3 + ldir + + CALL M_STOP + CALL M_FREE + + LD DE,#0x8000 + CALL M_ADR + + LD B,#4 + JP M_LOC + +INIT_BIOS_CONT: + xor a + ld de,#4*256+2 ;D=4 E=2 + call 0xFFCA + LD (DOSJMPTAB),HL + + LD IY,#CALL_SEG + LD (IY),#0xC9 ; ret + LD (IY),#0xC9 ; ?>??????>>//??? + RET + + +CALL_SEG: + ld iy,(0xFB1E-1) +CALL_SEG_INIT: JP 0xF200 + +; Check if replayer is installed +; output: if nz=0 not installed +; if z=1 installed + +CHECK_IF_INST: + LD HL,#ID_FB04 + LD DE,#0xFB04+21 + LD B,#5 +CHECK_IF_INST_LP: + LD A,(DE) + CP (HL) + RET NZ + INC HL + INC DE + DJNZ CHECK_IF_INST_LP + RET + +ID_FB04:.str "MBTSR" ; If this is on address FB04h+21 + +;============================= + +EXIT_ON_ERR: + DI + LD SP,(ST_STACK) + + CALL RESTORE_MEM + + LD HL,#INT_DOS + CALL PUT_INT + CALL SET_SCREEN0 + EI + RET + +GET_INT: + DI + LD DE,#0x38+1 + + LD A,(DE) + LD (HL),A + INC DE + INC HL + LD A,(DE) + LD (HL),A + EI + RET + +PUT_INT: + DI + LD DE,#0x38+1 + + LD A,(HL) + LD (DE),A + INC DE + INC HL + LD A,(HL) + LD (DE),A + EI + RET + +COLOR_WHITE: + DI + LD A,#0x0F + OUT (0x99),A + LD A,#0x87 + OUT (0x99),A + EI + RET +COLOR_BLACK: + DI + XOR A + OUT (0x99),A + LD A,#0x87 + OUT (0x99),A + EI + RET + +SPRITES_OFF: LD A,(0xFFE7) ; MOET ANDERS + OR #0b00000010 + OUT (0x99),A + LD A,#8+128 + OUT (0x99),A + RET + +SPRITES_ON: LD A,(0xFFE7) ; MOET ANDERS + AND #0b11111101 + OUT (0x99),A + LD A,#8+128 + OUT (0x99),A + RET + +PUT_SPRITE: + LD A,#1 + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + + LD A,#0x00 ; ff + OUT (0x99),A + LD A,#0x76 ; 35 + OUT (0x99),A + + LD BC,#0x0498 + OTIR + RET + +SCREEN_OFF: + LD IY,(0xFCC1) ; MOET ANDERS + LD IX,#0x41 + CALL 0x1C + EI + RET +SCREEN_ON: + LD IY,(0xFCC1) ; MOET ANDERS + LD IX,#0x44 + CALL 0x1C + EI + RET + +SET_SCREEN5: + LD A,#5 ; SCREEN 5 + LD IY,(0xFCC1) + LD IX,#0x5F + CALL 0x1C + EI + RET +SET_SCREEN0: + LD A,#80 + LD (0xF3AE),A + LD A,#0 ; SCREEN 0 + LD IY,(0xFCC1) + LD IX,#0x5F + CALL 0x1C + EI + RET + + +SET_PAGE: + DI + OUT (0x99),A + LD A,#2+128 + OUT (0x99),A + EI + RET + +PUT_COLOR: + DI + XOR A + OUT (0x99),A + LD A,#16+128 + OUT (0x99),A + + LD BC,#0x209A ; send 32(0x20) to 9A + OTIR + EI + RET + +GET_TIME: + LD C,#0x2C + JP DOS + + +NO_TXT: + XOR A + LD C,#2 + JP DOS + +PUT_TXT: + LD A,(0x0080) + BIT 7,A + JR NZ,NO_TXT + + LD A,(HL) + CP #0x1D + JR Z,PUT_TXT_DOME + LD E,A + LD C,#2 + PUSH HL + CALL DOS + POP HL + INC HL + JR PUT_TXT +PUT_TXT_DOME: + DI + XOR A + OUT (0x99),A + LD A,#14+128 + OUT (0x99),A + XOR A + OUT (0x99),A + LD A,#64 + OUT (0x99),A + LD HL,#TXT_DOME +PUT_TXT_DOME2: + LD A,(HL) + CP #0x0A + JR Z,PUT_TXT_DOME3 + OUT (0x98),A + INC HL + JR PUT_TXT_DOME2 +PUT_TXT_DOME3: + EI + RET +PUT_TXT2: + LD A,(HL) + CP #0x1D + RET Z + LD E,A + LD C,#2 + PUSH HL + CALL DOS + POP HL + INC HL + JR PUT_TXT2 + +ST_STACK: .dw 0 +INT_DOS: .dw 0 + + +TXT_DOME: .str " DOME : The Building of an Empire / Beta" + .str " Release at XX-XX-1999" + .db 0x0A + + + +RESTORE_MEM: + LD HL,#MEM_ORG+6 + LD B,(HL) + LD C,#0xC0 + CALL PUT_SLT + INC HL + LD A,(HL) + OUT (0xFF),A + + LD HL,#MEM_ORG + LD B,(HL) + LD C,#0x00 + CALL PUT_SLT + INC HL + + LD A,(HL) + EXX + LD DE,#0x18 + CALL DOS2_CALLTAB + EXX + INC HL + + LD B,(HL) + LD C,#0x40 + CALL PUT_SLT + INC HL + + LD A,(HL) + EXX + LD DE,#0x1E + CALL DOS2_CALLTAB + EXX + INC HL + + LD B,(HL) + LD C,#0x80 + CALL PUT_SLT + INC HL + + LD A,(HL) + EXX + LD DE,#0x24 + CALL DOS2_CALLTAB + EXX + RET + + +DOS2_CALLTAB: + LD HL,(DOSJMPTAB) + ADD HL,DE + PUSH HL + RET + +PUT_PAGE_FD: + LD B,(HL) + LD A,(MEM_TAB+1) ;PAGE 1 + LD C,#0x40 + CP B + CALL NZ,PUT_SLT + INC HL + LD A,(HL) + LD DE,#0x1E + LD HL,(DOSJMPTAB) + ADD HL,DE + PUSH HL + RET + +PUT_PAGE_FE: + LD B,(HL) + LD A,(MEM_TAB+2) ;PAGE 2 + CP B + LD C,#0x80 + CALL NZ,PUT_SLT + INC HL + LD A,(HL) + LD DE,#0x24 + LD HL,(DOSJMPTAB) + ADD HL,DE + PUSH HL + RET + +PUT_PAGE_FF: + LD B,(HL) + LD A,(MEM_TAB+3) ;PAGE 3 + LD C,#0xC0 + CP B + CALL NZ,PUT_SLT + + INC HL + LD A,(HL) + OUT (0xFF),A + + RET +PUT_SLT: + PUSH HL + LD A,B ; SLT ADR + LD H,C ; PAGE ADR + CALL ENASLT + POP HL + RET + +MEM_TAB: + .ds 4 +MEM_ORG: + .ds 8 + +INIT_BIOS_MEM: + LD HL,#TAB_LOC + LD DE,#MEM_TAB + LD A,(HL) + LD (DE),A ; SLT ADR VAN PAGE 0 + INC DE + INC HL + INC HL + LD A,(HL) + LD (DE),A ; SLT ADR VAN PAGE 1 + INC DE + INC HL + INC HL + LD A,(HL) + LD (DE),A ; SLT ADR VAN PAGE 2 + INC DE + INC HL + INC HL + LD A,(HL) + LD (DE),A ; SLT ADR VAN PAGE 3 + + LD HL,#TAB_LOC + LD DE,#MEM_ORG + LD BC,#8 + LDIR + RET + +M_MUSLOAD: + LD IX,#0x4000+(0*3) ; A=BANK + JP CALL_SEG ; DE=PIONTER2FILE(,0) +M_KITLOAD: + LD IX,#0x4000+(1*3) ; DE=PIONTER2FILE(,0) + JP CALL_SEG +M_PLAY: + LD IX,#0x4000+(2*3) ; A=BANK + JP CALL_SEG +M_STOP: + LD IX,#0x4000+(3*3) + JP CALL_SEG +M_CONT: + LD IX,#0x4000+(4*3) + JP CALL_SEG +M_FADE: + LD IX,#0x4000+(5*3) ; A=FADE SPEED + JP CALL_SEG +M_LOC: + LD IX,#0x4000+(6*3) ; B=NR OF SEGMENTS + JP CALL_SEG +M_FREE: + LD IX,#0x4000+(7*3) + JP CALL_SEG +M_MUSINFO: + LD IX,#0x4000+(8*3) ; DE=PIO2EMTYMEM(56) + JP CALL_SEG +M_ADR: + LD IX,#0x4000+(9*3) ; DE=MUS ADR + JP CALL_SEG +M_DRVINFO: + LD IX,#0x4000+(10*3) + JP CALL_SEG +M_DATA: + LD A,(0xFB1E) + PUSH HL + LD DE,#0x06 + LD HL,(DOSJMPTAB) + ADD HL,DE + PUSH HL + POP DE + POP HL + PUSH DE + RET + +DOSJMP: + LD HL,(DOSJMPTAB) + ADD HL,DE + PUSH HL + RET + +PUTBLK: + + DI ; vdp klaar ? + LD A,#2 ; waarde 2 in reg 15 + OUT (0x99),A + LD A,#0x8F ; execute + OUT (0x99),A + NOP + NOP ; wacht op vdp +PUTBLK_WAIT: + IN A,(0x99) ;lees status + RRA ; is CE nog 1 dan C is loop + JR C,PUTBLK_WAIT + + XOR A ; status reg. op 0 + OUT (0x99),A + LD A,#0x8F + OUT (0x99),A + + LD A,#0x20 ; register 32 + OUT (0x99),A ; als control register + LD A,#0x91 ;in reg 17 + OUT (0x99),A + LD BC,#0x0F9B ; 15 bytes naar port 9b + OTIR + EI + + RET + + +DOME_MENU_CALL: + LD HL,#DOME_MENU + CALL PUT_PAGE_FE + + ;CALL 0x8000 + + LD HL,#COPY0_1 + CALL PUTBLK + + LD HL,#DOME_CODE + CALL PUT_PAGE_FE + RET + +INIT_INT: + LD HL,#INT_MAIN + JP PUT_INT + +INT_MAIN: + .dw INT_ROUTINE + + +INT_ROUTINE: + DI + PUSH AF + PUSH BC + PUSH DE + PUSH HL + EX AF,AF + EXX + PUSH AF + PUSH BC + PUSH DE + PUSH HL + + PUSH IX + PUSH IY + + IN A,(0x99) + AND A + JP P,I_NOT_V9938 + + LD A,(INT_ON) + OR A + JR NZ,INT_ON_OFF + + CALL I_READ_BUTTONS + CALL READ_MOUSIE + CALL HOOK_VDP + +INT_ON_OFF: + POP IY + POP IX + + POP HL + POP DE + POP BC + POP AF + EX AF,AF + EXX + POP HL + POP DE + POP BC + POP AF + + EI + RETI + +I_NOT_V9938: + CALL 0xFD9A + CALL HOOK_INT + POP IY + POP IX + POP HL + POP DE + POP BC + POP AF + EX AF,AF + EXX + POP HL + POP DE + POP BC + POP AF + EI + RETI +HOOK_VDP: + CALL HOOK_RET ; +1 + CALL HOOK_RET ; +4 + CALL HOOK_RET ; +7 + JP HOOK_RET ; +10 +HOOK_INT: + CALL HOOK_RET ; +13 + CALL HOOK_RET ; +16 + CALL HOOK_RET ; +19 + JP HOOK_RET ; +21 +HOOK_RET: + RET + +; HOOK_ON +; IN : DE = 1/4/7/10(VDP) 13/16/19/21(NO VDP) +; HL = ADR VAN TE AAN TE ROEPEN ROUTINE +; + +HOOK_ON: + DI + PUSH HL + LD HL,#HOOK_VDP + ADD HL,DE + EX DE,HL + POP HL + + LD A,(HL) + LD (DE),A + INC DE + INC HL + LD A,(HL) + LD (DE),A + EI + RET +HOOK_OFF: + DI + LD HL,#HOOK_VDP + ADD HL,DE + EX DE,HL + + LD HL,#HOOK_RET + LD A,(HL) + LD (DE),A + INC DE + INC HL + LD A,(HL) + LD (DE),A + EI + RET + +READ_MOUSIE: + ; Gebruik spratr om x en y op te slaan ! + + LD A,(MOUSE_PORT) ; Get mouse port in C + LD C,A +MOUSE1: + LD A,(MOUSE_WAIT1) + LD B,A ; Get Y move + CALL READ_MOUSE + RLCA + RLCA + RLCA + RLCA + LD H,A + CALL READ_MOUSE + OR H + LD H,A + CALL READ_MOUSE ; Get X move + RLCA + RLCA + RLCA + RLCA + LD L,A + CALL READ_MOUSE + OR L + LD C,H ; B = X-move / C = Y-move + LD B,A + + LD A,B ; Move -1,-1 ? + INC A + LD H,A + LD A,C + INC A + OR H + JR NZ,MOUSE3 + + LD A,(MOUSE_USE) ; Check mouse use + OR A + JR NZ,MOUSE2 + + LD A,(MOUSE_PORT) ; Check other port + XOR #0b01000000 + LD (MOUSE_PORT),A + + JR KEYBOARD + +MOUSE2: + LD A,(MOUSE_OFF) ; na 20 keer -1,-1 is uit + INC A + LD (MOUSE_OFF),A + CP #20 + JR C,MOUSE4 + XOR A ; Deactivate mouse + LD (MOUSE_USE),A + + JR KEYBOARD + +MOUSE3: ; Activate mouse / Keep mouse activat + XOR A ; counter op 0 + LD (MOUSE_OFF),A + DEC A ; wordt weer gebruikt + LD (MOUSE_USE),A + +MOUSE4: + LD A,B ; If mouse is moved then skip keyboar + OR C + JR NZ,CHK_PIJL_BORD ; niet 0,0 dan check + +KEYBOARD: + ; nog even geen keyboard + RET + + +CHK_PIJL_BORD: ; In: B=y-coordinaat + + LD HL,#SPRATR + LD A,(HL) + SUB B + + BIT 7,B + JR NZ,CHK_PIJL_BORD_Y1 + JR NC,CHK_PIJL_BORD_Y3 + XOR A + JR CHK_PIJL_BORD_Y3 + +CHK_PIJL_BORD_Y1: + JR NC,CHK_PIJL_BORD_Y2 + CP #204 + JR C,CHK_PIJL_BORD_Y3 + +CHK_PIJL_BORD_Y2: + LD A,#203 + +CHK_PIJL_BORD_Y3: + LD (HL),A + INC HL + + LD A,(HL) + SUB C + BIT 7,C + JR NZ,CHK_PIJL_BORD_X1 + JR NC,CHK_PIJL_BORD_X3 + XOR A + JR CHK_PIJL_BORD_X3 + +CHK_PIJL_BORD_X1: + JR NC,CHK_PIJL_BORD_X2 + CP #249 + JR C,CHK_PIJL_BORD_X3 +CHK_PIJL_BORD_X2: + LD A,#248 + +CHK_PIJL_BORD_X3: + LD (HL),A + +MOUSE_SPRITE: + DEC HL + ; spratr in hl !! + + LD A,#1 + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + + LD A,#0x00 ; ff + OUT (0x99),A + LD A,#0x76 ; 35 + OUT (0x99),A + + LD BC,#0x0498 + OTIR + RET + +READ_MOUSE: + LD A,#15 + OUT (0xA0),A + LD A,C + OUT (0xA1),A + XOR #0b00110000 + LD C,A + LD A,#14 + OUT (0xA0),A +READ_MOUSE_L: + DJNZ READ_MOUSE_L + + LD A,(MOUSE_WAIT2) + LD B,A + IN A,(0xA2) + AND #0x0F + RET + +;----------------------------------------- + +I_READ_BUTTONS: + XOR A + CALL I_FIR_P1 + LD (MOUSE_BUTTONS),A + RET + +I_FIR_P1: + LD B,A ; A=0 PORT 1 / A=1 PORT 2 + LD A,#15 + + OUT (0xA0),A + NOP + IN A,(0xA2) + + DJNZ I_FIR_S1 + AND #0xDF + OR #0x4C + JR I_FIR_S2 +I_FIR_S1: + AND #0xAF + OR #3 +I_FIR_S2: + OUT (0xA1),A + LD A,#14 + OUT (0xA0),A + NOP + IN A,(0xA2) + RET + +CHK_SPATIE: + IN A,(0xAA) ; check op spatie... + AND #0xF0 + OR #8 + OUT (0xAA),A + IN A,(0xA9) + AND #1 + RET + + +RUN_GAME: + PUSH AF ; LEVEL NR + + ;LD HL,#INT_DOS + ;CALL PUT_INT + ;HALT + + LD HL,#DOME_CODE + CALL PUT_PAGE_FE + LD HL,#DOME_VELD + CALL PUT_PAGE_FD + + POP AF + DAA + JP C,EXIT_ON_ERR ; LEVEL NR HOGER DAN ==> QUIT + + LD HL,#L_VELD_WR+2 + CALL RUN_GAME_EXT + LD HL,#L_CODE_WR+2 + CALL RUN_GAME_EXT + LD HL,#L_TANK_WR+2 + CALL RUN_GAME_EXT + + LD DE,#0x1000 + LD BC,#0x500 + LD HL,#L_CODE + LD A,#0 + CALL LOAD + + CALL 0x100F ; BRIEFING CODE + + CALL SCREEN_OFF + + LD HL,#DOME_CODE + CALL PUT_PAGE_FE + LD HL,#DOME_VELD + CALL PUT_PAGE_FD + + LD DE,#0x2000 + LD BC,#0x1000 + LD HL,#L_TANK + LD A,#0 + CALL LOAD + + LD DE,#0x4000 + LD BC,#0x4000 + LD HL,#L_VELD + LD A,#7 ; 7 BYT HEADER + CALL LOAD + + LD DE,#0x8000 + LD BC,#0x6000 ; 22 kb MAX + LD HL,#L_GAME + LD A,#0 + CALL LOAD + + + LD HL,#DOME_GFX_UNIT + LD A,(HL) + OR A + JR Z,NO_GFX_GAME1 + CALL PUT_PAGE_FD + + LD HL,#0x4000 ; UNITTOT + LD DE,#0x0 + LD A,#1 + CALL POP_UP_START + + LD HL,#DOME_GFX_BLPA + LD A,(HL) + OR A + JR NZ,NO_GFX_GAME2 + CALL PUT_PAGE_FD + + LD HL,#0x4000 ; BALKEN + LD DE,#0x8000 + LD A,#0 + CALL POP_UP_START + + LD HL,#COPY0_1 + CALL PUTBLK + + LD HL,#DOME_VELD + CALL PUT_PAGE_FD + + LD HL,#0x6000 ; PAGE 5 + LD DE,#0x8000 + LD A,#1 + CALL POP_UP_START + + LD HL,#DOME_VELD + CALL PUT_PAGE_FD + LD HL,#DOME_CODE + CALL PUT_PAGE_FE + + LD HL,#COLOR_DOME_GAME + CALL PUT_COLOR + + CALL SCREEN_ON + + DI + LD A,#1 + CALL M_PLAY + + JP 0x8000 + +NO_GFX_GAME1: + LD HL,#DOME_TEMP + CALL PUT_PAGE_FD + + LD HL,#UNITTOT + LD DE,#0x4000 ; OVER HET VELD + LD BC,#0x3000 + LD A,#0 + CALL LOAD + LD HL,#0x4000 ; UNITTOT + LD DE,#0x0 + LD A,#1 + CALL POP_UP_START + +NO_GFX_GAME2: + LD HL,#DOME_TEMP + CALL PUT_PAGE_FD + + LD HL,#BALKEN4 + LD DE,#0x4000 + LD BC,#0x1000 + LD A,#0 + CALL LOAD + LD HL,#0x4000 ; BALKEN + LD DE,#0x8000 + LD A,#0 + CALL POP_UP_START + LD HL,#COPY0_1 + CALL PUTBLK + + LD HL,#PAGE5 + LD DE,#0x4000 + LD BC,#0x2000 + LD A,#0 + CALL LOAD + LD HL,#0x4000 ; PAGE 5 + LD DE,#0x8000 + LD A,#1 + CALL POP_UP_START + + LD HL,#DOME_VELD + CALL PUT_PAGE_FD + LD HL,#DOME_CODE + CALL PUT_PAGE_FE + + LD HL,#COLOR_DOME_GAME + CALL PUT_COLOR + + CALL SCREEN_ON + + DI + LD A,#1 + CALL M_PLAY + + JP 0x8000 + + + +RUN_GAME_EXT: + + + RET + + + +COPY0_1: + .db 0,0,0,1 + .db 0,0,0,0 + .db 0,1,212,0 + .db 0,0,0xD0 + +L_VELD: .str "VELD " +L_VELD_WR: .str "001" +L_CODE: .str "CODE " +L_CODE_WR: .str "001" +L_TANK: .str "TANKTAB " +L_TANK_WR: .str "001" +L_GAME: .str "DOME DAT" +BALKEN4: .str "BALKEN4 ZOP" +UNITTOT: .str "UNITTOT ZOP" +PAGE5: .str "PAGE5 ZOP" + +COLOR_DOME_GAME: + .db #0x00,#0x00,#0x62,#0x04,#0x52,#0x03,#0x50,#0x02 + .db #0x23,#0x02,#0x20,#0x01,#0x53,#0x04,#0x11,#0x01 + .db #0x00,#0x04,#0x45,#0x04,#0x40,#0x01,#0x72,#0x05 + .db #0x04,#0x01,#0x06,#0x02,#0x00,#0x00,#0x77,#0x07 + + +;======================================================================= + + +POPPAG: .db 0 +POPIFF: .db 0 +POPEND: .dw 0 +POPXXX: .dw 0 +POPBUF: .ds 256 + +POPTBL: + .db 7 ; Mapperbank ( niet gebruikt ? ) +PAGE: .db 0 ; VDP-page (64 kB or b16 of VRAM-add +DATA: .dw 0 ; Source address (in RAM) +ADRES: .dw 0 ; Dest. address (in VRAM) + .dw 0 ; End address (in VRAM, is calculated + + +POP_UP_START: + LD (PAGE),A + LD (ADRES),DE + LD (DATA),HL + + LD A,(MSX_TYPE) + CP #3 + LD A,#0 + LD IY,(0xFCC1) + LD IX,#0x0180 + CALL Z,0x1C + + LD A,(INT_ON) + PUSH AF + LD A,#255 + LD (INT_ON),A + + XOR A + CALL POP_UP + + POP AF + LD (INT_ON),A + + LD A,(MSX_TYPE) + CP #3 + RET NZ + LD A,#2 + LD IY,(0xFCC1) ; NUL (BIOS SLT) + LD IX,#0x0180 + JP 0x1C + + + +POP_UP: ADD A + ADD A + ADD A + LD E,A + LD D,#0 + LD IX,#POPTBL + ADD IX,DE ; [IX]=POPTBL+8*[A] + + LD A,I ; IFF to P/V-flag + LD A,#-1 ; mm is FF -1 + JP PE,POP_DI + XOR A +POP_DI: LD (POPIFF),A ; Interrupt status (0: DI; -1: EI) + + LD A,1(IX) + LD (POPPAG),A ; VDP-page (64 kB) + + LD L,2(IX) + LD H,3(IX) ; Source address in [HL] + LD E,(HL) + INC HL + LD D,(HL) ; Length in [DE] + LD L,4(IX) + LD H,5(IX) ; Dest. address in [HL] + ADD HL,DE + LD (POPEND),HL ; Set end address + + LD L,4(IX) + LD H,5(IX) ; Dest. address in [HL] + CALL POP_WR ; Set VDP to write + + LD L,2(IX) + LD H,3(IX) ; Source address in [HL] + LD DE,#0x0004 + ADD HL,DE ; Skip 4 bytes (the 2 addresses) + LD BC,#0x1098 + OTIR ; Write 1st 16 bytes in VRAM + + LD E,#0x80 + EXX + LD L,4(IX) + LD H,5(IX) ; Dest. address in [HL] + LD DE,#0x0010 + ADD HL,DE ; Skip 16 bytes +POP_00: LD A,(POPEND+1) + CP H + JR NZ,POP_01 + LD A,(POPEND) + CP L + RET C + RET Z ; Return when (POPEND)<=[HL] +POP_01: EXX + RLC E + JR NC,POP_02 + LD D,(HL) + INC HL +POP_02: RLC D + LD A,(HL) + INC HL + JR C,POP_03 + EXX + + CALL POP_WR + OUT (0x98),A ; Write in VRAM + INC HL + JR POP_00 +; +POP_03: BIT 7,A + JR NZ,POP_04 + EXX + LD D,#0x00 + LD E,A + EXX + XOR A + JR POP_05 +; +POP_04: BIT 6,A + JR NZ,POP_06 + RES 7,A + LD BC,#0x0400 +POP_07: RLC E + JR NC,POP_08 + LD D,(HL) + INC HL +POP_08: RLC D + RLA + RL C + DJNZ POP_07 + ADD A,#0x80 + EXX + LD E,A + EXX + LD A,C + ADC A,#0x00 + EXX + LD D,A + EXX + LD A,#0x01 + JR POP_05 +; +POP_06: AND #0x3F + SRL A + EXX + LD D,A + EXX + LD A,(HL) + INC HL + RRA + EXX + LD E,A + EXX + LD A,#0x02 + JR NC,POP_09 + LD C,#0x01 + JR POP_0A +; +POP_05: LD C,A + INC A + RLC E + JR NC,POP_0B + LD D,(HL) + INC HL +POP_0B: RLC D + JR NC,POP_09 +POP_0A: INC A + RLC E + JR NC,POP_0C + LD D,(HL) + INC HL +POP_0C: RLC D + JR NC,POP_09 + INC A + RLC E + JR NC,POP_0D + LD D,(HL) + INC HL +POP_0D: RLC D + JR NC,POP_09 + LD A,#0x02 +POP_0E: RLC E + JR NC,POP_0F + LD D,(HL) + INC HL +POP_0F: RLC D + JR NC,POP_10 + INC A + CP #0x07 + JR NZ,POP_0E +POP_10: LD B,A + LD A,#0x01 +POP_11: RLC E + JR NC,POP_12 + LD D,(HL) + INC HL +POP_12: RLC D + RLA + DJNZ POP_11 + ADD A,C +POP_09: EXX + + PUSH AF + PUSH HL + + LD (POPXXX),HL ; write address in (popxxx) + SCF + SBC HL,DE ; read address in [HL] + LD C,#0x98 + CALL POP_13 ; Simulate 'LDIR' in VRAM + + POP HL + POP AF + LD C,A + LD B,#0 + INC BC + ADD HL,BC ; [HL#]=[HL]+[A]+1 + JP POP_00 + +POP_13: LD B,A + INC DE + LD A,D + OR A + JP NZ,POP_15 ; [DE]>255 = [D]>0: no overlap + + LD A,B ; [B]=len-1 + SUB E ; [E]=x + JP C,POP_15 ; [B]<[E]: no overlap (len<=x) + + INC B + PUSH BC + LD B,E + CALL POP_RD ; read address still in [HL] + LD HL,#POPBUF + INIR ; read x bytes in VRAM + + LD C,A + LD B,#0 + INC BC ; [BC]=len-x + LD HL,#POPBUF + ADD HL,DE + EX DE,HL ; [DE]=POPBUF+x + LD HL,#POPBUF ; [HL]=POPBUF + LDIR + +POP_14: POP BC + LD HL,(POPXXX) + CALL POP_WR + LD HL,#POPBUF + OTIR ; write bytes in VRAM + RET + +POP_15: INC B + PUSH BC + CALL POP_RD ; read address still in [HL] + LD HL,#POPBUF + INIR ; read bytes in VRAM + JP POP_14 + +POP_WR: PUSH BC ; Set write address + LD C,A + LD A,(POPPAG) + LD B,A + LD A,H + AND #0b11000000 + OR B + RLCA + RLCA + DI + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + LD A,L + LD A,L + OUT (0x99),A + LD A,H + AND #0x3F + OR #0x40 + OUT (0x99),A + + LD A,(POPIFF) + OR A + LD A,C + POP BC + RET Z ; Restore int. status + EI + RET + +POP_RD: PUSH BC ; Set read address + LD C,A + LD A,(POPPAG) + LD B,A + LD A,H + AND #0b11000000 + OR B + RLCA + RLCA + DI + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + LD A,L + LD A,L + OUT (0x99),A + LD A,H + AND #0x3F + OUT (0x99),A + + LD A,(POPIFF) + OR A + LD A,C + POP BC + RET Z ; Restore int. status + EI + RET + + + +SAVE: + RET + +; IF A=NOT 254 OR A=NOT 255 THEN +; +; HL= FILE NAME (LOAD_BIN) +; DE= DMA-ADR +; A= HEADER TRACH +; BC= LENGTE +; ELSE +; HL= FILE NAME (LOAD_LIB) +; DE= DMA-ADR +; +; IF A=255 THEN CLOSE_LIB +; END + + +LOAD: + JP LOAD_BIN + ;CP #254 ; CLOSE LIB ON EXIT + ;JR C,LOAD_BIN ; KLEINER DAN + + ;EX AF,AF + ;PUSH HL + ;CALL SETDMA ; ADR + ;POP HL + ;CALL OPEN + ;CALL SEARCH_FILE ; if found lengte in HL + ;CALL READ + + ;EX AF,AF + ;CP #255 + ;RET NZ + ;JP CLOSE + +;--------- + +PUT_TXT_FILE: + LD A,(HL) + LD E,A + LD C,#2 + PUSH HL + PUSH BC + CALL DOS + POP BC + POP HL + INC HL + DJNZ PUT_TXT_FILE + RET + +FILE_ERROR: .str " NOT FOUND" ; 10 len + +LOAD_BIN: + PUSH BC + PUSH AF + PUSH DE + + CALL PUT_NAM_FCB + CALL OPEN + cp #0 + jr z,store_open_f + +; wip q&d error code; + LD HL,#FILENAME + LD B,#11 + CALL PUT_TXT_FILE + LD HL,#FILE_ERROR + LD B,#10 + CALL PUT_TXT_FILE + ld e,#0x0A + ld c,#0x02 + call DOS + ld e,#0x0D + ld c,#0x02 + call DOS + +store_open_f: + POP DE + CALL SETDMA + + POP HL + ; skip bytes ?? + ;LD L,H ; KAN ?? + ;LD H,#0 + ;CALL READ ; kan dit ?? + + POP HL + CALL READ ; op oude DMA adres ??? + JP CLOSE ; ja !! raar he ?! + +; Zoek file op in directory en stel record number in +; In: HL: adres te laden file-naam +; DE: adres directory +; Uit: HL: lengte file +; A: 0 indien gelukt, 255 indien mislukt + +SEARCH_FILE: + LD DE,#DIRECTORY ; eerste2 bytes zijn aantal files +SEARCH_FILE0: + + PUSH HL ; adres naam v.d. file + PUSH DE ; adres directory + + CALL CMP_STR + OR A + JR Z,SEARCH_FILE1 + + POP DE + LD HL,#11 + 2 + 3 + ADD HL,DE + EX DE,HL ; DE = positie in directory + POP HL + JR SEARCH_FILE0 + +SEARCH_FILE1: ; HL = adres in directory + EX DE,HL + + LD E,(HL) + INC HL + LD D,(HL) ; laad lengte + INC HL + PUSH DE + + LD DE,#FCB + 33 + LD BC,#3 + LDIR ; Record Number naar FCB + + XOR A ; drive ?? + LD (DE),A + + POP HL ; lengte in HL + + POP DE + POP DE + RET + +CMP_STR: + LD B,#11 +CMP_STR1: + LD A,(DE) + CP (HL) + RET NZ + INC HL + INC DE + DJNZ CMP_STR1 + XOR A + RET + + + +; Laad directory +; In: HL: Adres filename +; DE: Bestemmingsadres directory + +INIT_LIB: + LD DE,#DIRECTORY + + PUSH DE + PUSH DE + + CALL PUT_NAM_FCB ; put HL in FCB + CALL OPEN + + POP DE + CALL SETDMA ; destination is DIRECTORY + + LD HL,#2 + CALL READ + + POP HL ; In BC aantal files + LD C,(HL) + INC HL + LD B,(HL) + + LD HL,#0 + LD DE,#11 + 3 + 2 ; lengte entry = name + +CALC_LENGTH: + ADD HL,DE + DEC BC + LD A,B + OR C + JR NZ,CALC_LENGTH + + CALL READ ; lees directory struct + + JP CLOSE + + +;========================================================================= +;========================================================================= +;=================== SUBS ============================================== +;========================================================================= +;========================================================================= + + +PUT_NAM_FCB: ; ; In: HL = file name pointer + LD DE,#FCB+1 + LD BC,#0x0B ; Out: A = drive name (0 = def., 1 = + LDIR ; Cng: HL,DE BC,AF + XOR A + LD (FCB),A ; (DRVNAM) must be valid + RET + +SETDMA: + LD C,#D_SETDMA ; DE=ADR + JP DOS +OPEN: + LD DE,#FCB + LD C,#D_OPEN + CALL DOS + LD HL,#0x01 + LD (FCB+14),HL ; Record length = 1 byte + DEC L + LD (FCB+33),HL + LD (FCB+35),HL ; Current record number = 0 + RET + +READ: + LD DE,#FCB + LD C,#D_READ ; HL=NR BYTES + JP DOS + +CLOSE: + LD DE,#FCB + LD C,#D_CLOSE + JP DOS + +FCB: .db 0 +FILENAME: .str " " +BLOCK: .dw #00 +RECORDLENGTH: .dw #00 +FILELENGTH: .dw #00,#00 +SYSTEMVAR: .dw #00,#00,#00,#00,#00,#00 + .db 0 +RECORDNR: .dw #00,#00 + +DIRECTORY: + .db 0 ; 7 BYTES PER FILE OF 11+3+2 suckS + ; ; NAAM - LENGTE - REC.NUM + +.area _DATA diff --git a/src/dome/0module.mk b/src/dome/0module.mk new file mode 100644 index 0000000..20ace90 --- /dev/null +++ b/src/dome/0module.mk @@ -0,0 +1,20 @@ + +DOME_NAME := dome +DOME_SRC := $(PATH_SRC)/$(DOME_NAME) +DOME_BIN := $(PATH_BIN)/$(DOME_NAME) +DOME_HEX := $(DOME_BIN)/$(DOME_NAME).hex +DOME_DAT := $(DOME_BIN)/$(DOME_NAME).dat +DOME_RELS := $(DOME_BIN)/$(DOME_NAME).rel +DOME_CODE := $(DOME_SRC)/$(DOME_NAME).asm + +$(DOME_BIN): + $(call mod_mkdir,$(DOME_BIN)) + +$(DOME_BIN)/%.rel: $(DOME_SRC)/%.asm | $(DOME_BIN) + $(call mod_compile_asm,$@,$<) + +$(DOME_HEX): $(DOME_RELS) + $(call mod_link_asm_8000,$(DOME_HEX),$(DOME_RELS)) + +$(DOME_DAT): $(DOME_HEX) + $(call mod_hex2dat,$(DOME_HEX),$(DOME_DAT)) diff --git a/src/dome/ai_new.asm b/src/dome/ai_new.asm new file mode 100644 index 0000000..97f7477 --- /dev/null +++ b/src/dome/ai_new.asm @@ -0,0 +1,1207 @@ + .dw 0x002F +AI: + JR AI_WAIT + CALL AI_UPDATE_TNKS + CALL AI_ADD_TNKS + RET + +AI_WAIT: + LD BC,(AI-2) + DEC BC + LD (AI-2),BC + LD A,B + OR C + RET NZ + + LD HL,#AI + LD (HL),#0 + INC HL + LD (HL),#0 + RET +AI_UPDATE_TNKS: + LD IX,#TANKRED + LD B,#127 ; ONLY RED + LD C,#TANK_DATA +AI_UPDATE_LP: + LD A,(IX) + OR A + JR Z,AI_UPDATE_NXT ; NO TNK + + LD A,(IX) + AND #0b01100000 + JR NZ,AI_UPDATE_NXT ; ATT NOT + + PUSH BC + CALL AI_UPDATE_TEST + POP BC +AI_UPDATE_NXT: + LD E,C ; tankdata + LD D,#0 + ADD IX,DE + DJNZ AI_UPDATE_LP + RET + +AI_UPDATE_TEST: + LD A,(IX) + AND #0b00000111 + JP Z,AI_HARVR ; HARV ( RET IS NEXT TANK !!!) + + LD A,(IX) + AND #0x0F + LD HL,#AI_MS_TAB ; TAB VOOR UPDATE MS + SLA A + LD C,A + LD B,#0 + ADD HL,BC + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + JP (HL) + +AI_MS_TAB: + .dw AI_MS15 ; RANDOM ATTACK ALS MS=0 + .dw AI_MS01 ; HARV PROTECT + .dw AI_MS02 ; HOOK #1 + .dw AI_MS03 ; HOOK #2 + .dw AI_MS04 ; RANDOM RIJDEN + .dw AI_MS05 ; PROTECT #1 + .dw AI_MS06 ; PROTECT #2 + .dw AI_MS07 ; PROTECT #3 + .dw AI_MS08 ; PROTECT #4 + .dw AI_MS09 ; MAKE ARMY #1 + .dw AI_MS10 ; MAKE ARMY #2 + .dw AI_MS11 ; FULL HOUSE #1 + .dw AI_MS12 ; FULL HOUSE #2 + .dw AI_MS13 ; FULL HOUSE #3 + .dw AI_MS14 ; FULL HOUSE #4 + .dw AI_MS15 ; RANDOM ATT + +;================================================================================ + +AI_MS01: + LD A,(IX) + BIT 7,A + JP Z,AI_MS01_NEXT ; BLAUWE + + CALL A_TO_IY + LD A,(IY) + OR A + JP Z,AI_MS01_NEXT ;LEEG + + LD A,(IY) + AND #7 + JP NZ,AI_MS01_NEXT ; GEEN HARV + + LD A,(IY) + OR A + JR NZ,AI_MS01_ATT ; ATT + + BIT 4,(IX) ; MOVING + RET NZ + + LD B,(IY) + LD C,(IY) ; 1=RIJDEN NAAR DES. + + LD A,B + SUB #4 + CP (IX) + RET C + + ; LD A,B + ; ADD A,4 + ; CP (IX) + ; RET C + + ; LD A,C + ; SUB A,4 + ; CP (IX) + ; RET NC + + ; LD A,C + ; ADD A,4 + ; CP (IX) + ; RET C + +AI_MS01_LP: + LD B,(IY) + LD C,(IY) + + LD HL,#RAD_HARVR + LD A,R + SRL A ; NIET MEER DAN 64 AFK + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD A,(HL) + + LD B,(IY) ; X + ADD B ; X+AFK + OR A + JP Z,AI_MS01_LP + CP #63 + JP NC,AI_MS01_LP + LD B,A + + LD C,(IY) ; Y + INC HL + LD A,(HL) + ADD C ; Y+AFK + OR A + JP Z,AI_MS01_LP + CP #63 + JP NC,AI_MS01_LP + LD C,A + + PUSH BC + CALL CALC_ADR + POP BC + LD A,(HL) + CP #48 + JP NC,AI_MS01_LP + + LD (IX),B + LD (IX),C ; NEW X.Y + + RET + +AI_MS01_ATT: + LD (IX),A ; NR KLOOJOO + RES 4,(IX) + SET 5,(IX) ; HARV ONDER ATT + RES 6,(IX) + RET + +AI_MS01_NEXT: + LD IY,#TANKRED ; (IX)=NO HARV + LD B,#127 + LD DE,#TANK_DATA +AI_MS01_NEXT_LP: + LD A,(IY) + OR A + JR Z,AI_MS01_NOT + + LD A,(IY) ; GEEN CHK OP LEEG ??? + AND #0b00000111 ; harvester + JR NZ,AI_MS01_NOT + + LD A,(IY) + LD (IX),A ; HARV FOUND + RET +AI_MS01_NOT: + ADD IY,DE + DJNZ AI_MS01_NEXT_LP + + LD A,(IX) + AND #0xF0 + LD (IX),A ; MIS 15/0 + RET +;================================================================================ +AI_MS02: + ;JP 0x3455 +AI_MS03: + ;JP 0x243R + RET +;================================================================================ +AI_MS04: + BIT 4,(IX) ; MOVING + RET NZ + + LD A,R + AND #0b00111111 + LD B,A + + HALT ; DIT IS OM R TE VERANDEREN ( MOET !! + + LD A,R + AND #0b00111111 + LD C,A + + PUSH BC + CALL CALC_ADR + POP BC + LD A,(HL) + CP #48 + RET NC ; STOON + + INC HL + LD A,(HL) + OR A + RET NZ ; TANK + + ; LD A,B + ; AND 0b00110000 + ; SRL A + ; LD E,A + + ; LD A,C + ; AND 0b00110000 + ; ADD A + ; OR E + ; LD D,0 + ; LD E,A + ; LD IY,AI_SECTORS + ; ADD IY,DE + + ; LD A,(IY) + ; OR A + ; RET NZ ; GEEN BLAUW IN SECTOR + + LD (IX),B + LD (IX),C + RET +;================================================================================ +AI_MS05: +AI_MS06: +AI_MS07: +AI_MS08: + BIT 4,(IX) + RET NZ + + LD HL,#AI_PAT_COR + LD A,C + SUB #10 + LD C,A + SLA C ; 4 + SLA C ; 8 POSITIONS + ADD HL,BC +AI_MS_PAT_LP: + LD D,(HL) + INC HL + LD E,(HL) + INC HL + + LD A,D + OR A ; EINDE TAB + RET Z ; DUS GEEN PLEKJE + + LD B,D + LD C,E + PUSH HL + CALL CALC_ADR + LD A,(HL) + CP #48 + JP NC,AI_MS_PAT_NEXT + + INC HL + LD A,(HL) + OR A + JR NZ,AI_MS_PAT_NEXT + POP HL + + LD (IX),D ; NEW X,Y + LD (IX),E + RET + +AI_MS_PAT_NEXT: + POP HL + JR AI_MS_PAT_LP + +AI_PAT_COR: + .db 32,36,05,15,62,62,0,0 + .db 55,35,38,38,61,61,0,0 + .db 36,36,33,60,60,60,0,0 + .db 54,05,50,30,59,59,0,0 + +;================================================================================ + +AI_MS09: +AI_MS10: + RET + +;================================================================================ + +AI_MS11: + LD A,(AI_MS11_ATT_NR) + JR AI_MS_FULL +AI_MS12: + LD A,(AI_MS12_ATT_NR) + JR AI_MS_FULL +AI_MS13: + LD A,(AI_MS13_ATT_NR) + JR AI_MS_FULL +AI_MS14: + LD A,(AI_MS14_ATT_NR) +AI_MS_FULL: + OR A + JR NZ,AI_MS_FULL_ATT ; DO_ATT + + BIT 4,(IX) + RET NZ ; MOVING + + LD A,(IX) + AND #0x0F + LD HL,#AI_MS_COUNTER + SLA A + LD C,A + LD B,#0 + ADD HL,BC ; Spreekt voor zich !! ja ?? + LD A,(HL) + LD B,A + INC HL + LD A,(HL) + CP B + JP Z,AI_MS_FULL_MAKE_ATT + + LD A,R + AND #0b01010101 + RET NZ + +AI_MS_FULL_MOVE: + LD B,(IX) + LD C,(IX) + + LD A,B + AND #0b00110000 + SRL A + SRL A + SRL A + SRL A + LD E,A + + LD A,C + AND #0b00110000 + SRL A + SRL A + OR E + + DEC A ; EEN VAK TERUG + AND #0x0F + CALL AI_XYRAN_SECTOR + + PUSH BC + CALL CALC_ADR + POP BC + LD A,(HL) + CP #48 + JP NC,AI_MS_FULL_MOVE + + INC HL ; 2TNK LAY + LD A,(HL) + OR A + JR NZ,AI_MS_FULL_MOVE + + LD (IX),B ; NEW X,Y + LD (IX),C + RET + +AI_MS_FULL_ATT: + OR A + RET Z + + BIT 7,A + JR NZ,AI_MS_FULL_NUL + + CALL A_TO_IY + + LD A,(IY) + OR A + JR Z,AI_MS_FULL_NUL + + LD (IX),A + RES 4,(IX) + SET 5,(IX) + RES 6,(IX) + RET +AI_MS_FULL_NUL: + LD HL,#AI_MS11_ATT_NR + LD (HL),#0 + INC HL + LD (HL),#0 + INC HL + LD (HL),#0 + INC HL + LD (HL),#0 + RET + +AI_MS_FULL_MAKE_ATT: + LD A,R + OR A + JR Z,AI_MS_FULL_MAKE_ATT + BIT 7,A + JR NZ,AI_MS_FULL_MAKE_ATT + CALL A_TO_IY + LD A,(IY) + OR A + RET Z + LD B,A + LD A,(IX) + AND #0x0F + SUB #11 + LD HL,#AI_MS11_ATT_NR + LD E,A + LD D,#0 + ADD HL,DE + LD A,B + LD (HL),A + RET + +AI_MS11_ATT_NR: + .db 0 +AI_MS12_ATT_NR: + .db 0 +AI_MS13_ATT_NR: + .db 0 +AI_MS14_ATT_NR: + .db 0 + +AI_XYRAN_SECTOR: + LD C,A + AND #3 + ADD A + ADD A + ADD A + ADD A + LD B,A + LD A,R + AND #0x0F + OR B + LD B,A + + HALT ; VOOR DE RANDOM ( MOET !!!!:) + + LD A,C + AND #12 + ADD A + ADD A + LD C,A + LD A,R + AND #0x0F + OR C + LD C,A + RET + +;================================================================================ +AI_MS15: + LD A,R + RES 7,A ; ALTIJD BLAUW + OR A + JR Z,AI_MS15 ; R= 4 OF 3 + CALL A_TO_IY + LD A,(IY) + OR A + RET Z ; NO TNK + LD (IX),A + RES 4,(IX) + SET 5,(IX) ; ATT + RES 6,(IX) + RET +;================================================================================ +;================================================================================ + +AI_HARVR: + BIT 4,(IX) + JP NZ,AI_HRVR_RIJT + + BIT 7,(IX) + JP Z,AI_HRVR_NO + + DEC (IX) ; 2=NET DOEN ALSOF EVEN HARVESTEN + RET NZ + + LD A,(IX) + LD (IX),A + + LD B,(IX) + LD C,(IX) ; 1=RIJDEN NAAR DES. + + PUSH BC + CALL CALC_ADR + POP BC ; 3=KIJK OP HRV + + LD A,(HL) + CP #16 + JP C,AI_HRVR_NO ; NEE RIJ VERDER + CP #48 + JP NC,AI_HRVR_NO ; + + CALL AI_CALC_HRV2MON + + RES 7,(IX) ; ANDER HRVED HIJ 2X OP DIK ZAND + INC B + XOR A + LD (IX),A + + LD HL,(AI_MONEY) + LD C,B + LD B,#0 + ADD HL,BC + RET C ; ANDERS KOMEN OP BIJ DE NUL + LD (AI_MONEY),HL + + RET + +;--------- NO HARV ----------------------- + +AI_HRVR_NO: + LD HL,#RAD_HARVR + LD A,(IX) + INC (IX) ; SEARCH IN CIRCLE + SLA A + LD C,A + LD B,#0 + ADD HL,BC + + LD A,(HL) + CP #100 + JP Z,AI_STOP_HRVR + + LD B,(IX) ; X + ADD B ; X+AFK + JP M,AI_HRVR_NO ; NEG + CP #63 + JP NC,AI_HRVR_NO ; >63 EINDE VELD + LD B,A + + LD C,(IX) ; Y + INC HL + LD A,(HL) + ADD C ; Y+AFK + JP M,AI_HRVR_NO ; NEG + CP #63 + JP NC,AI_HRVR_NO ; >63 EINDE VELD + LD C,A + + PUSH BC ; NEW X,Y + CALL CALC_ADR + POP BC + + LD A,(HL) ; IS ER HARVEST + CP #16 + JP C,AI_HRVR_NO + CP #48 + JP NC,AI_HRVR_NO + + LD (IX),B ; INIT NEW X,Y + LD (IX),C + + SET 7,(IX) ; SET HARV BIT'JE + XOR A + LD (IX),A ; SET WAIT COUNTER VAN RIJDEN + LD (IX),A ; POS IN SEARCH CICLE + RET +AI_HRVR_RIJT: + LD A,(IX) ; CONTER OM TE RIJEN + INC A + AND #0b00111111 + LD (IX),A + RET NZ + + LD B,(IX) + LD C,(IX) ; WAAR WILLEN WE HEEN ??/ + CALL CALC_ADR + INC HL + LD A,(HL) ; STAAT DAAR EEN TNK + OR A + RET Z ; JE HEBT AL EN DOEL + + CALL A_TO_IY + LD A,(IY) + BIT 7,A + JR NZ,AI_HRVR_FREND + + LD (IX),A ; DE KLOOJOO = MISSIE MAAKT HEM AFFF + RET +AI_HRVR_FREND: + LD HL,#RAD_HARVR + LD A,R + SRL A ; NIET MEER DAN 64 AFK'EN + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD A,(HL) + + LD B,(IY) ; X + ADD B ; X+AFK + CP #63 + JP NC,AI_HRVR_FREND + LD B,A + + LD C,(IY) ; Y + INC HL + LD A,(HL) + ADD C ; Y+AFK + CP #63 + JP NC,AI_HRVR_FREND + LD C,A + + LD (IY),B + LD (IY),C ; NEW X.Y + + RET +AI_STOP_HRVR: + XOR A + LD (IX),A + RES 7,(IX) ; ECHT VAST + RET + RET +AI_ADD_TNKS: + + + LD HL,#AI_WAIT_COUNTER + LD A,(HL) + DEC (HL) + OR A + RET NZ + + LD A,#50 + LD (AI_WAIT_COUNTER),A + + LD A,(AI_BUILD_CAR) + OR A + RET NZ + + LD A,R + AND #0b00000011 + LD (AI_CAR_TYPE),A + + SLA A + SLA A + LD C,A + LD B,#0 + LD HL,#ETB_VALUE + ADD HL,BC + LD A,(HL) + CP #1 + RET NZ + LD (HL),#2 ; tank wordt in de wachtrij gezet + + LD A,(AI_CAR_TYPE) + LD B,A + LD A,#4 + SUB B + LD (AI_CAR_TYPE),A + + LD A,#1 + LD (AI_BUILD_CAR),A + RET + +AI_CREATE_CAR: + PUSH BC + CALL AI_CREATE_CARI + POP BC + RET + +AI_CREATE_CARI: + PUSH HL ; push bb_bar adres + + LD HL,#BUILDING_RED + INC HL ; build type + LD C,#BUILD_DATA + LD B,#25 ; 25 gebouwen van AI +AI_LOOP_CRT_CAR: + PUSH HL + PUSH BC + LD A,(HL) + CP #4 ; gevonden ? dan createcar + CALL Z,AI_CREATE_CAR2 + POP BC + POP HL + LD A,B + LD B,#0 + ADD HL,BC + LD B,A + DJNZ AI_LOOP_CRT_CAR + + POP HL ; terug naar orig. loop + ; CALL COLOR_WHITE + RET ; mag eigenlijk niet hier komen + ; komt hier als geen enkele factory kan plaatsen +AI_CREATE_CAR2: + ; ; if gevonden POP stack en cont + ; ; else RET + INC HL + LD B,(HL) ; ? + DEC B + INC HL + LD C,(HL) ; hoekje factory + + CALL CALC_ADR + + LD DE,#FACTORY_DEPLOY +AI_CAR2_LP: + LD A,(DE) + CP #100 + RET Z ; volgende factory + + PUSH HL + + LD A,(DE) + LD C,A + INC DE + LD A,(DE) + LD B,A + INC DE + ADD HL,BC + LD A,(HL) + CP #80 + JR NC,AI_CAR2_LP2 ; kan niet op rots of huis + INC HL + LD A,(HL) + OR A + JR NZ,AI_CAR2_LP2 ; kan niet op tank + JR AI_CREATE_CAR3 +AI_CAR2_LP2: + POP HL + JR AI_CAR2_LP + RET ; probeer volgende factory + +AI_CREATE_CAR3: + POP AF ; BC + POP AF ; HL + POP AF ; adres + POP AF ; ret adres + + LD BC,#VELD_ADRES + SBC HL,BC + SRL L + SRL L + LD A,L + LD L,H ; HL = x & y + LD H,A + + LD A,(AI_CAR_TYPE) + LD C,A + LD B,#0 ;rood + CALL ADD_TANK + + POP HL + LD (HL),#1 ; clear tank bar + INC HL ; dit pas NA dat + LD A,(HL) ; de tank gebouwd is + INC HL + DEC A + LD (HL),A + + DEC HL + DEC HL + + XOR A + LD (AI_BUILD_CAR),A + ; LD BC,25 + ; LD (AI_WAIT_COUNTER),BC + RET ; terug org.loop +;----------------------------------- +; TANK CHECK. +; +; if any red tank is in the vicinity +; then attack mode +;----------------------------------- +TNK_CHK: + ; CALL COLOR_WHITE + + LD B,(IX) + LD C,(IX) + CALL CALC_ADR + INC HL ; NAAR TNK LAYER + + LD A,(IX) + AND #0x80 + LD D,A ; BIT 7=OORSPORNG REQETER + + DEC H ; UP + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + INC HL ; RIUP + INC HL + INC HL + INC HL + + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + INC H ; RI + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + INC H ; RIDO + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + DEC HL ; DO + DEC HL + DEC HL + DEC HL + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + DEC HL ; DOLI + DEC HL + DEC HL + DEC HL + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + DEC H ; LI + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + + DEC H ; LIUP + LD A,(HL) + OR A + CALL NZ,FOUND_TNK + RET +FOUND_TNK: + CALL A_TO_IY + LD A,(IY) + LD B,A + AND #0x80 + SUB D + RET Z ; CHK OP SOORT + + LD (IX),B + RES 4,(IX) + SET 5,(IX) + RES 6,(IX) + POP AF ; DO NOP FINCH CIRCLE + RET +;--------------------------------------- +; TANK CHECK HELP VOOR BLAUW +; +; Zorgt ervoor dat de blauwe units +; elkaar helpen ! +;--------------------------------------- +TNK_CHK_HELP: + ; alleen even voor blauw + ; CALL COLOR_WHITE + + BIT 7,(IX) + RET NZ + + LD B,(IX) + LD C,(IX) + CALL CALC_ADR + INC HL ; NAAR TNK LAYER + + ; LD A,(IX) + ; LD D,A + + DEC H ; UP + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + INC HL ; RIUP + INC HL + INC HL + INC HL + + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + INC H ; RI + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + INC H ; RIDO + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + DEC HL ; DO + DEC HL + DEC HL + DEC HL + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + DEC HL ; DOLI + DEC HL + DEC HL + DEC HL + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + DEC H ; LI + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + + DEC H ; LIUP + LD A,(HL) + OR A + CALL NZ,FOUND_TNK2 + RET +FOUND_TNK2: + CALL A_TO_IY ; + LD A,(IY) + BIT 7,A + RET NZ ; alleen blauwe mogen helpen + + LD A,(IY) + AND #0b01110000 + RET NZ ; ATT & MOVE AFMAKEN + + LD A,(IX) + LD (IY),A + RES 4,(IY) + SET 5,(IY) + RES 6,(IY) + ; POP AF ; CIRLE AF MAKEN + RET + +;------------------------------------ +; In : IX adres van harvester blauw +;------------------------------------ +AI_HARVB: + BIT 7,(IX) + RET NZ ; GEEN RODE + + BIT 7,(IX) ;niet aan het harvesten + JP Z,AI_HARVB_EMPTY + + LD A,(IX) + CP #70 + JP Z,AI_HARVB_NULL + + DEC (IX) ; counter + RET NZ + LD A,(IX) + LD (IX),A + + LD B,(IX) + LD C,(IX) + CALL CALC_ADR + + LD A,(HL) + CP #48 + JP NC,AI_HARVB_CHK_R ;GEEN harvest gevonden + CP #16 + JP C,AI_HARVB_CHK_R ; GEEN harvest gevonden + + ; sta op harvest + ; maak leeg en bepaal volgende stukje + + CALL AI_CALC_HRV2MON + + LD A,(IX) + ADD B + LD (IX),A + CP #70 ; 700 MONEY + JR NC,AI_HARVB_RET_B ;return to base + + ; bepaal volgende stukje + + JR AI_HARVB_CHK_R + +AI_HARVB_RET_B: + LD A,#70 ;mooi afronden + LD (IX),#70 ; jammer van de rest + + LD A,(IX) + LD (IX),A ; waar die vandaan kwam + LD A,(IX) + LD (IX),A + + RES 7,(IX) ; harv uit + ; en dan terug rijden + LD A,#50 ;ix+26 <> 0 is return aan ! + LD (IX),A ; is tegelijk de wachtlus + JP HARV_RETURN2 + + +AI_HARVB_CHK_R: + LD IY,#RAD_HARVB + LD D,(IX) + LD E,(IX) +AI_HARVB_CHK_RL: + LD A,(IY) + CP #100 + JR Z,AI_HARVB_NULL + + ADC A,D + LD B,A + + INC IY + LD A,(IY) + ADC A,E + LD C,A + + INC IY + PUSH BC + CALL CALC_ADR + POP BC + LD A,(HL) + CP #16 + JR C,AI_HARVB_CHK_RL + CP #48 + JR NC,AI_HARVB_CHK_RL + + INC HL + LD A,(HL) + OR A + CALL NZ,AI_HARV_MOVEIT + + LD (IX),B ; rij daar heen + LD (IX),C + RET + +AI_HARV_MOVEIT: + BIT 7,A ;rood mag niet uitwijken + RET NZ + + CALL A_TO_IY ; random ergens anders + LD A,R ; maar wel in de buurt + AND #0b00000011 + ADD D + LD (IY),A + LD A,R + AND #0b00000011 + ADD E + LD (IY),A + RET + +AI_HARVB_NULL: + ; geen harvest in cirkel kunnen vinden + RES 7,(IX) + LD A,(IX) + OR A + JR NZ,AI_HARVB_RET_B ; naar refinery terug + + RET ; stop maar + +AI_HARVB_EMPTY: + LD A,(IX) + OR A + RET Z + + LD A,(IX) + OR A + JR Z,AI_HARVB_EMPTY2 + LD C,A + LD (IX),#0 + + LD HL,(MONEY) + LD B,#0 + ADD HL,BC + RET C + LD (MONEY),HL + RET +AI_HARVB_EMPTY2: + LD A,(IX) + DEC A + LD (IX),A + RET NZ + + LD B,(IX) + LD C,(IX) + LD A,B + OR C + RET Z ; naar 0,0 is nix ! + + LD (IX),B + LD (IX),C + SET 7,(IX) + RET + +; ------------------------------------- +; harvest to money +; IN HL = adres van harvest +; uit B = money +;-------------------------------------- + +AI_CALC_HRV2MON: + LD A,(HL) + + LD C,#0 + LD B,#10 + CP #16 + JR Z,AI_CALC_2 + + LD C,#16 + LD B,#10 + CP #32 + JR Z,AI_CALC_2 + + LD C,#16 + LD B,#8 + CP #39 + JR NC,AI_CALC_2 + + LD C,#16 + LD B,#4 + CP #33 + JR NC,AI_CALC_2 + + LD C,#0 + LD B,#8 + CP #25 + JR NC,AI_CALC_2 + + LD C,#0 + LD B,#4 +AI_CALC_2: + LD A,C + OR A + JR Z,AI_CALC_3 + + LD A,(HL) + SUB C +AI_CALC_3: + LD (HL),A + RET + +AI_UPDATE: + RET + +AI_CHK_REPAIR: + RET +AI_CHK_REBUILD: + RET + +AI_WAIT_COUNTER: .db 50 + +AI_BUILD_CAR: .db 0 +AI_CAR_TYPE: .db 0 +AI_BUILD_BLD: .db 0 + ; 0 = niets doen + ; iets anders is ID building/car + +AI_CUR_LEVEL: .dw AI_LEVELAI + +AI_LEVELAI: .db 1,0,0 ; 1 = level + .db 2,1,0 ; 2 = types of car + .db 3,1,0 ; 3 = level building + .db 4,2,3 + .db 5,2,4 + .db 6,3,4 + .db 7,3,5 + .db 8,4,5 + .db 9,4,6 + .db 10,4,7 + +AI_MS_COUNTER: + .db 0,0 ; current/max + .db 0,4 ; PROTECT HARV -- MISSIO + .db 0,0 ; HOOK #1 -- MISSION 2 + .db 0,0 ; HOOK #2 -- MISSION 3 + .db 0,2 ; RANDOM RIJDEN -- MISSIO + .db 0,2 ; PROTECT #1 -- MISSIO + .db 0,3 ; PROTECT #2 -- MISSIO + .db 0,4 ; PROTECT #3 -- MISSIO + .db 0,3 ; PROTECT #4 -- MISSIO + .db 0,0 ; MAKE ARMY #1 -- MISSIO + .db 0,0 ; MAKE ARMY #2 -- MISSIO + .db 0,0 ; FULL HOUSE #1 -- MISSIO + .db 0,0 ; FULL HOUSE #2 -- MISSIO + .db 0,0 ; FULL HOUSE #3 -- MISSIO + .db 0,3 ; FULL HOUSE #4 -- MISSIO + .db 0,4 ; RANDOM ATT -- MISSIO + +AI_MONEY: + .dw 400 ; 24 CAR'S + HARV = 25 KILL'S + diff --git a/src/dome/dome.asm b/src/dome/dome.asm new file mode 100644 index 0000000..ef5b90a --- /dev/null +++ b/src/dome/dome.asm @@ -0,0 +1,8425 @@ +;-------------------------------------- +; DOME +; +; (c) 1997 / 98 / 99 Paragon Productions +; +;-------------------------------------- + +DOS .equ 0x5 +ENASLT .equ 0x24 + +GET_INT .equ 0x0100 +PUT_INT .equ 0x0103 +COLOR_WHITE .equ 0x0106 +COLOR_BLACK .equ 0x0109 +SCREEN_ON .equ 0x010C +SCREEN_OFF .equ 0x010F +SET_SCREEN0 .equ 0x0112 +SET_SCREEN5 .equ 0x0115 +SPRITES_ON .equ 0x0118 +SPRITES_OFF .equ 0x011B +;PUT_SPRITE .equ 0x011E +SET_PAGE .equ 0x0121 +GET_TIME .equ 0x0124 +PUT_TXT .equ 0x0127 +PUT_TXT2 .equ 0x012A +INIT_BIOS .equ 0x012D +EXIT_ON_ERR .equ 0x0130 +LOAD .equ 0x0133 +INIT_LIB .equ 0x0136 +SAVE .equ 0x0139 +PUT_PAGE_FD .equ 0x013C +PUT_PAGE_FE .equ 0x013F + +INIT_REP .equ 0x0142 +LOAD_MUS .equ 0x0145 +LOAD_SAM .equ 0x0148 +;PLAY .equ 0x014B +;STOP .equ 0x014E +FADE .equ 0x0151 +NEXT .equ 0x0154 +MUS_NR .equ 0x0157 +POP_UP_START .equ 0x015A +;PUTBLK .equ 0x015D +PUT_COLOR .equ 0x0160 +DOME_MENU_CALL .equ 0x0163 +RESTORE_MEM .equ 0x0166 +INIT_BIOS_MEM .equ 0x0169 +RUN_GAME .equ 0x016C +;INT_ROUTINE .equ 0x016F +HOOK_ON .equ 0x0172 +HOOK_OFF .equ 0x0175 +INIT_INT .equ 0x0178 + + +; last modification date 5-04-99 + +JIFFY .equ 0xFC9E ; wordt nog gebruikt + +TANK_DATA .equ 32 ; 32 bytes +BUILD_DATA .equ 13 +VELD_ADRES .equ 0x4000 + +TANKTAB .equ 0x2000 +TANK1 .equ 0x2000+32 ;adres tank tabel !!!!!!!!!!!!!!!!! +TANKRED .equ 0x2000+128*TANK_DATA + +;------------- DOME ---------------- kick off !! + +.area _CODE + ; org 0x8000 +ST: + LD (EXIT_STACK),SP + CALL INIT_DUNE2 + XOR A + LD (EVENT),A +MAIN_LOOP: + LD A,(FIRE_BUTTONS) + BIT 4,A + JR NZ,RESET_BUTTON0 + CALL Z,CHECK_COOR +MAIN_LOOP2: + LD A,(FIRE_BUTTONS) + BIT 5,A + JR NZ,RESET_BUTTON1 + CALL Z,CANCELACTION +MAIN_LOOP3: + ; CALL CHK_SPATIE + ; CALL Z,TEST_ADD_TNK + ; CALL NZ,SPICE_BOOM + + LD A,(STOP) + OR A + JP NZ,EXIT_DUNE2 + + CALL UPDATE_EVENT + JR MAIN_LOOP + +UPDATE_EVENT: + LD A,(EVENT) + INC A + CP #6 + JR NZ,UPD2 + XOR A +UPD2: + LD (EVENT),A + LD HL,#EVENTHANDLER + SLA A + LD C,A + LD B,#0 + ADD HL,BC + LD E,(HL) + INC HL + LD D,(HL) + EX DE,HL + JP (HL) +RESET_BUTTON0: + LD HL,#BUT_PRESSED + RES 0,(HL) + JR MAIN_LOOP2 +RESET_BUTTON1: + LD HL,#BUT_PRESSED + RES 1,(HL) + JR MAIN_LOOP3 + +;----------------------------------------- + +INIT_DUNE2: + LD A,#0 + LD (B_BALK_NR),A + LD A,#8 + LD (T_BALK_NR),A + LD A,#0 + LD (B_BALK_TYPE),A + + CALL INIT_BBAR + CALL MMODULE_INIT + + LD HL,#CPYTT + + LD B,#79 + XOR A +LOOP0: LD (HL),A + INC HL + DJNZ LOOP0 + + LD (STOP),A + + LD HL,(ADR) + LD BC,#9*256+17*4 + ADD HL,BC + LD (ADR),HL + + LD A,#18 + LD (OFFSET),A + LD A,#10 + LD (OFFSET+1),A + + LD IX,#SPRATR+4 ; radar sprite + LD 0(IX),#128+10 + LD 1(IX),#193+18 + + ; even roode cc yard erbij + + CALL MAKE_RED_BASE + + CALL FREE_BLW_BASE ; creer gezichtsveld 1e keer + + ;-------------------- + CALL PUT_SPRITE ; radarsprite + CALL INIT_RADAR ; maak radar + CALL PUT_MONEY ; plaatsmoney + CALL CLEAR_ITEM ; maak itemscherm schoon + + CALL INIT_MOUSE ; start mouse lookup + + LD HL,#INT_GAME + CALL PUT_INT ; PUT ADR DOME-INT + + HALT ; geef buttons een kans + RET +;------------------------------------- + +INIT_MOUSE: + LD A,#15 + OUT (0xA0),A + IN A,(0xA2) + AND #0x8F + OR #0x30 + LD (MOUSE_PORT),A + XOR A + LD (MOUSE_USE),A + LD (MOUSE_OFF),A + + LD HL,#0x002D + LD A,#0 ;(0xFCC1) ; SLOT ADR BIOS = 0 + CALL 0x0C ; interslot call + + CP #3 + JR Z,INIT_MOUSE_TR + + LD A,#31 + LD (MOUSE_WAIT1),A + LD A,#10 + LD (MOUSE_WAIT2),A + RET +INIT_MOUSE_TR: + LD A,#31*5 + LD (MOUSE_WAIT1),A + LD A,#10*5 + LD (MOUSE_WAIT2),A + RET + +;----------------------------------------- + +EXIT_DUNE2: + JP EXIT_ON_ERR + RET + +;------------------------------------------------- +; check op scrollen randjes +;------------------------------------------------ + +CHKXY: + LD IX,#SPRATR+4 + CALL PUT_SPRITE + + LD D,#4 + +SCRL: + LD A,(MOUSEX) + CP #245 + JP NC,SCRL_R + + CP #4 + JP C,SCRL_L + + LD A,(MOUSEY) + CP #200 + JP NC,SCRL_D + + CP #4 + JP C,SCRL_U + + LD A,(CURSOR_TYPE) + LD (MOUSE_SHAPE),A + RET + +SCRL_R: + LD A,#16 + LD (MOUSE_SHAPE),A + + LD HL,#MAXSET + LD A,(OFFSET) + CP (HL) + RET Z + INC A + LD (OFFSET),A + INC 1(IX) + + LD HL,(ADR) + LD B,#0 + LD C,D + ADD HL,BC + LD (ADR),HL + + CALL BUILD + JP CHKXY + +SCRL_L: + LD A,#24 + LD (MOUSE_SHAPE),A + + LD A,(OFFSET) + CP #1 + RET Z + DEC A + + LD (OFFSET),A + DEC 1(IX) + + LD HL,(ADR) + LD B,#0 + LD C,D + SBC HL,BC + LD (ADR),HL + + CALL BUILD + JP CHKXY + +SCRL_D: + LD A,#20 + LD (MOUSE_SHAPE),A + + LD HL,#MAXSET+1 + LD A,(OFFSET+1) + CP (HL) + RET Z + + INC A + + LD (OFFSET+1),A + INC 0(IX) + + XOR A + LD HL,(ADR) + + INC H + + LD (ADR),HL + CALL BUILD + JP CHKXY + +SCRL_U: + LD A,#12 + LD (MOUSE_SHAPE),A + + LD A,(OFFSET+1) + CP #1 + RET Z + + DEC A + + LD (OFFSET+1),A + DEC 0(IX) + + XOR A + LD HL,(ADR) + + DEC H + + LD (ADR),HL + CALL BUILD + JP CHKXY + +;---------------- Tabel update !!!---------- + +CX: .db 0 +CY: .db 0 + + +UPDATE: + LD IX,#TANK1 +UPDATELOOP: + LD A,13(IX) + OR A + CALL NZ,TEST_WAT_NU + + LD DE,#TANK_DATA + ADD IX,DE + LD HL,#TOTTANK + DEC (HL) + JP NZ,UPDATELOOP + + LD A,#254 + LD (TOTTANK),A + RET + +TOTTANK: .db 254 + +TEST_WAT_NU: + BIT 4,11(IX) + JP NZ,DO_MOVE + + CALL IMPACT_GFX + + BIT 6,11(IX) + JP NZ,DO_ATTACK + + JP CHECK_MOVE + RET + +DO_MOVE: + LD A,6(IX) + OR A + JR Z,UPDATEXY + + DEC 6(IX) ; verlaag de step byte + LD A,4(IX) ; x offset + SUB 7(IX) ; x speed eraf + + LD 4(IX),A + LD A,5(IX) + SUB 8(IX) ; y speed eraf + + LD 5(IX),A + + RET + +UPDATEXY: + LD 4(IX),#0 + LD 5(IX),#0 + LD 6(IX),#0 + LD 7(IX),#0 + LD 8(IX),#0 + + BIT 5,23(IX) ; DIT BIT JE IS GUARD + CALL NZ,TNK_CHK ; KIJK EEN RONDJE OM ZICH HEEN + +CHECK_MOVE: + BIT 5,11(IX) + CALL NZ,ATT_MOVE ; geen jump ?? WEL DUS !! + + LD A,15(IX) + AND #0b11110000 + JP NZ,AFWK_MOVE + + LD A,0(IX) + SUB 2(IX) + LD B,A + LD A,#0 + RL A + LD (CX),A + LD A,1(IX) + SUB 3(IX) + LD C,A + LD A,#0 + RL A + LD (CY),A + LD A,B + OR C + JP Z,TURN_ROUND + + XOR A + LD A,0x00(IX) + SUB 0x02(IX) + JP Z,J82F1 + + LD A,0x01(IX) + SUB 0x03(IX) + JP Z,J82E6 + + LD A,(CX) + OR A + JR Z,SCHUIN + + LD A,(CY) + OR A + JP Z,POSITIE_2 + JP POSITIE_4 + +SCHUIN: LD A,(CY) + OR A + JP Z,POSITIE_8 + JP POSITIE_6 + +J82E6: LD A,(CX) + OR A + JP Z,POSITIE_7 + JP POSITIE_3 + +J82F1: LD A,(CY) + OR A + JP Z,POSITIE_1 + JP POSITIE_5 + +POSITIE_1: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKUP + LD A,#1 + JP NZ,POS1_KAN + + CALL CHKUPLT + LD A,#1+(8*16) + JP NZ,POS8_KAN + + CALL CHKUPRI + LD A,#1+(2*16) + JP NZ,POS2_KAN + + CALL CHKLT + LD A,#1+(7*16) + JP NZ,POS7_KAN + + CALL CHKRI + LD A,#1+(3*16) + JP NZ,POS3_KAN + + JP TANK_VAST + +POSITIE_2: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKUPRI + LD A,#2 + JP NZ,POS2_KAN + + CALL CHKUP + LD A,#2+(1*16) + JP NZ,POS1_KAN + + CALL CHKRI + LD A,#2+(3*16) + JP NZ,POS3_KAN + + CALL CHKUPLT + LD A,#2+(8*16) + JP NZ,POS8_KAN + + CALL CHKDORI + LD A,#2+(4*16) + JP NZ,POS4_KAN + + JP TANK_VAST + +POSITIE_3: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKRI + LD A,#3 + JP NZ,POS3_KAN + + CALL CHKUPRI + LD A,#3+(2*16) + JP NZ,POS2_KAN + + CALL CHKDORI + LD A,#3+(4*16) + JP NZ,POS4_KAN + + CALL CHKUP + LD A,#3+(1*16) + JP NZ,POS1_KAN + + CALL CHKDN + LD A,#3+(5*16) + JP NZ,POS5_KAN + + JP TANK_VAST + +POSITIE_4: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKDORI + LD A,#4 + JP NZ,POS4_KAN + + CALL CHKDN + LD A,#4+(5*16) + JP NZ,POS5_KAN + + CALL CHKRI + LD A,#4+(3*16) + JP NZ,POS3_KAN + + CALL CHKUPRI + LD A,#4+(2*16) + JP NZ,POS2_KAN + + CALL CHKDOLT + LD A,#4+(6*16) + JP NZ,POS6_KAN + + JP TANK_VAST + +POSITIE_5: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKDN + LD A,#5 + JP NZ,POS5_KAN + + CALL CHKDOLT + LD A,#5+(6*16) + JP NZ,POS6_KAN + + CALL CHKDORI + LD A,#5+(4*16) + JP NZ,POS4_KAN + + CALL CHKLT + LD A,#5+(7*16) + JP NZ,POS7_KAN + + CALL CHKRI + LD A,#5+(3*16) + JP NZ,POS3_KAN + + JP TANK_VAST + +POSITIE_6: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKDOLT + LD A,#6 + JP NZ,POS6_KAN + + CALL CHKLT + LD A,#6+(7*16) + JP NZ,POS7_KAN + + CALL CHKDN + LD A,#6+(5*16) + JP NZ,POS5_KAN + + CALL CHKUPLT + LD A,#6+(8*16) + JP NZ,POS8_KAN + + CALL CHKDORI + LD A,#6+(4*16) + JP NZ,POS4_KAN + + JP TANK_VAST + +POSITIE_7: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKLT + LD A,#7 + JP NZ,POS7_KAN + + CALL CHKDOLT + LD A,#7+(6*16) + JP NZ,POS6_KAN + + CALL CHKUPLT + LD A,#7+(8*16) + JP NZ,POS8_KAN + + CALL CHKUP + LD A,#7+(1*16) + JP NZ,POS1_KAN + + CALL CHKDN + LD A,#7+(5*16) + JP NZ,POS5_KAN + + JP TANK_VAST + +POSITIE_8: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + LD D,H + LD E,L + + CALL CHKUPLT + LD A,#8 + JP NZ,POS8_KAN + + CALL CHKUP + LD A,#8+(1*16) + JP NZ,POS1_KAN + + CALL CHKLT + LD A,#8+(7*16) + JP NZ,POS7_KAN + + CALL CHKUPRI + LD A,#8+(2*16) + JP NZ,POS2_KAN + + CALL CHKDOLT + LD A,#8+(6*16) + JP NZ,POS6_KAN + + JP TANK_VAST + +POS1_KAN: LD 15(IX),A +POS10KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + DEC H + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS10KAN1 + LD (HL),B +POS10KAN1: + LD 0x09(IX),#0 + LD A,0x0A(IX) + LD 0x07(IX),#0 + ; NEG + LD 0x08(IX),A + ; NEG + + LD 4(IX),#0 + LD 5(IX),#16 + DEC 1(IX) ; Y=Y-1 + + JP SPEED_STEP + +POS2_KAN: LD 15(IX),A +POS20KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + DEC H ; - 256 + INC HL + INC HL + INC HL + INC HL ; + 4 + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS20KAN1 + LD (HL),B +POS20KAN1: + + LD 0x09(IX),#1 + LD A,0x0A(IX) + NEG + LD 0x07(IX),A + NEG + ; NEG + LD 0x08(IX),A + ; NEG + + LD 4(IX),#-16 + LD 5(IX),#16 + INC 0(IX) ; X=X-1 + DEC 1(IX) ; Y = Y -1 + + JP SPEED_STEP + +POS3_KAN: LD 15(IX),A +POS30KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + INC HL + INC HL + INC HL + INC HL + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS30KAN1 + LD (HL),B +POS30KAN1: + + LD 0x09(IX),#2 + LD A,0x0A(IX) + NEG + LD 0x07(IX),A + NEG + LD 0x08(IX),#0 + + LD 4(IX),#-16 + LD 5(IX),#0 + INC 0(IX) ; X=X+1 + JP SPEED_STEP + +POS4_KAN: LD 15(IX),A +POS40KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + INC HL + INC HL + INC HL + INC HL + INC H + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS40KAN1 + LD (HL),B +POS40KAN1: + + LD 0x09(IX),#3 + LD A,0x0A(IX) + NEG + LD 0x07(IX),A + LD 0x08(IX),A + NEG + + LD 4(IX),#-16 + LD 5(IX),#-16 + INC 0(IX) ; X=X-1 + INC 1(IX) ; Y = Y -1 + JP SPEED_STEP + +POS5_KAN: LD 15(IX),A +POS50KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + INC H + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS50KAN1 + LD (HL),B +POS50KAN1: + + LD 0x09(IX),#4 + LD A,0x0A(IX) + NEG + LD 0x08(IX),A + NEG + LD 0x07(IX),#0 + + LD 4(IX),#0 + LD 5(IX),#-16 + INC 1(IX) ; Y = Y + 1 + JP SPEED_STEP + +POS6_KAN: LD 15(IX),A +POS60KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + INC H + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS60KAN1 + LD (HL),B +POS60KAN1: + + LD 0x09(IX),#5 + LD A,0x0A(IX) + ; NEG + LD 0x07(IX),A + ; NEG + NEG + LD 0x08(IX),A + NEG + + LD 4(IX),#16 + LD 5(IX),#-16 + DEC 0(IX) ; X=X-1 + INC 1(IX) ; Y = Y -1 + JP SPEED_STEP + +POS7_KAN: LD 15(IX),A +POS70KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS70KAN1 + LD (HL),B +POS70KAN1: + + LD 0x09(IX),#6 + LD A,0x0A(IX) + LD 0x07(IX),A + LD 0x08(IX),#0 + + LD 4(IX),#16 + LD 5(IX),#0 + DEC 0(IX) ; X=X-1 + JP SPEED_STEP + +POS8_KAN: LD 15(IX),A +POS80KAN: SET 4,0x0B(IX) + + CALL RES_TANK_LAY + DEC HL + DEC HL + DEC HL + DEC HL + DEC H + LD (HL),A + DEC HL + DEC HL + LD A,(HL) + OR A + JR Z,POS80KAN1 + LD (HL),B +POS80KAN1: + + LD 0x09(IX),#7 + LD A,0x0A(IX) + ; NEG + LD 0x07(IX),A + LD 0x08(IX),A + ; NEG + + LD 4(IX),#+16 + LD 5(IX),#16 + DEC 0(IX) ; X=X-1 + DEC 1(IX) ; Y = Y -1 + JP SPEED_STEP + +TANK_VAST: LD A,0(IX) ; kan geen kant op !! + LD 2(IX),A + LD A,1(IX) + LD 3(IX),A + LD 15(IX),#0 + LD 7(IX),#0 + LD 8(IX),#0 + RET + +AFWK_MOVE: LD A,15(IX) + AND #0b00001111 + LD HL,#CHK_TABEL + DEC A + SLA A + SLA A + LD C,A + LD B,#0 + ADD HL,BC + PUSH HL + + LD DE,#DYNACALL+1 + LD A,(HL) + LD (DE),A + INC HL + INC DE + LD A,(HL) + LD (DE),A + + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + + CALL DYNACALL + POP HL + JR Z,J84FB + + LD 15(IX),#0 + INC HL + INC HL + LD DE,#DYNAJUMP+1 + LD A,(HL) + LD (DE),A + INC DE + INC HL + LD A,(HL) + LD (DE),A + JP DYNAJUMP + RET + +J84FB: LD HL,#CHK_TABEL + LD A,15(IX) + AND #0b11110000 + SRL A + SRL A + SUB #4 + + LD C,A + LD B,#0 + ADC HL,BC + PUSH HL + LD DE,#DYNACALL+1 + LD A,(HL) + LD (DE),A + INC HL + INC DE + LD A,(HL) + LD (DE),A + + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + + CALL DYNACALL + POP HL + JR Z,REVERSE_MOVE + + INC HL + INC HL + LD DE,#DYNAJUMP+1 + LD A,(HL) + LD (DE),A + INC DE + INC HL + LD A,(HL) + LD (DE),A + JP DYNAJUMP + RET + +REVERSE_MOVE: + LD 15(IX),#0 + RET + +DYNACALL: CALL 0x0 + RET + +DYNAJUMP: JP 0x0 + +CHK_TABEL: + .dw CHKUP+2 + .dw POS10KAN + .dw CHKUPRI+2 + .dw POS20KAN + .dw CHKRI+2 + .dw POS30KAN + .dw CHKDORI+2 + .dw POS40KAN + .dw CHKDN+2 + .dw POS50KAN + .dw CHKDOLT+2 + .dw POS60KAN + .dw CHKLT+2 + .dw POS70KAN + .dw CHKUPLT+2 + .dw POS80KAN + + +ATT_MOVE: ; ;attack en doel zoeken + BIT 3,11(IX) + JP NZ,ATT_MOVE_B ; op 1 is gebouw aanvallen + + LD A,11(IX) ; type tank + AND #0b00000111 + SLA A + LD HL,#RADARS + LD C,A + LD B,#0 + ADD HL,BC + + LD E,(HL) + INC HL + LD D,(HL) + EX DE,HL + + LD A,14(IX) + PUSH IX + CALL A_TO_IX + LD B,0(IX) ; doel enemy + LD C,1(IX) ; doel enemy + POP IX + LD D,0(IX) + LD E,1(IX) + +CHECK_AROUND: LD A,(HL) + CP #100 + JR Z,END_CHK_RND + + XOR A + LD A,B + ADC A,(HL) + CP D + INC HL + JR NZ,J85A0 + + XOR A + LD A,C + ADC A,(HL) + CP E + JR Z,FND_TARGET +J85A0: + INC HL + JP CHECK_AROUND + +FND_TARGET: + LD A,B ; set geattacked coor in ix+20 & 21 + LD 20(IX),A + LD A,C + LD 21(IX),A + + LD E,(HL) + DEC HL + LD D,(HL) + + CALL CALC_RICHT + + LD A,0(IX) ; set x en y op einde + LD 2(IX),A + LD A,1(IX) + LD 3(IX),A + RES 4,11(IX) ; reset move bit + RES 5,11(IX) ; reset att move bit + SET 6,11(IX) ; set att bit + + POP AF ; return adres van stack af einde + ; ; update subroutine + RET + +END_CHK_RND: ; eindcoordinaat + LD 2(IX),B + LD 3(IX),C + RET +;------------------------------- +; ATTACK GEBOUW +;------------------------------- + +ATT_MOVE_B: + LD A,11(IX) ; type tank + AND #0b00000111 + SLA A + LD HL,#RADARS + LD C,A + LD B,#0 + ADD HL,BC + + LD E,(HL) + INC HL + LD D,(HL) + EX DE,HL + + LD B,2(IX) ; doel gebouw + LD C,3(IX) ; doel gebouw (loopt echt niet weg !) + LD D,0(IX) ; gebouw kan hooguit al kapot zijn! + LD E,1(IX) ; huidige coordinaten + +CHECKAROUND2: LD A,(HL) + CP #100 + RET Z ;nog niet in zicht dus rij maardoor + + XOR A + LD A,B + ADC A,(HL) + CP D + INC HL + JR NZ,CONT_001 + + XOR A + LD A,C + ADC A,(HL) + CP E + JR Z,FND_TAR_BLD +CONT_001: + INC HL + JP CHECKAROUND2 + +FND_TAR_BLD: + CALL COLOR_WHITE + + LD E,(HL) + DEC HL + LD D,(HL) + + CALL CALC_RICHT + + LD A,0(IX) + LD 2(IX),A + LD A,1(IX) + LD 3(IX),A + LD 4(IX),#0 + LD 5(IX),#0 + RES 5,11(IX) + SET 6,11(IX) ; set do_attack bitje + RET +;---------------------------------- +; berekend de richting waarheen de tank moet staan ! +;-------------------------------- +CALC_RICHT: + LD C,#4 + LD A,D + OR A + JR Z,TARGET_XNUL + RL A + JR C,TARGET_XNEG + + LD A,E + OR A + JR Z,TARGET_YNUL + RL A + JR C,TARGET_YNEG + + INC C +TARGET_YNUL: + INC C +TARGET_YNEG: + INC C + JP SET_RICHTING +TARGET_XNEG: + LD A,E + OR A + JR Z,TARGET_YNUL2 + RL A + JR C,TARGET_YNEG2 + + DEC C +TARGET_YNUL2: + DEC C +TARGET_YNEG2: + DEC C + JP SET_RICHTING + +TARGET_XNUL: + RL E + LD C,#0 + JR NC,SET_RICHTING + LD C,#4 + JP SET_RICHTING + +SET_RICHTING: + LD 9(IX),C ; radar found bitje ook weer op 0 + RET +;--------------------------------------- + +TURN_ROUND: + RES 4,11(IX) ; move uit ! + + LD A,13(IX) + CP #127 + JR NC,CONT_TURNR + + BIT 7,9(IX) + JR NZ,CONT_TURNR + SET 7,9(IX) + + LD A,11(IX) ; type tank + AND #0b00000111 + SLA A + LD HL,#RADARS + LD C,A + LD B,#0 + ADD HL,BC + LD E,(HL) + INC HL + LD D,(HL) + +TURN_LOOP: + LD A,(DE) + CP #100 + JR Z,CONT_TURNR + + ADD 1(IX) + LD C,A + + INC DE + LD A,(DE) + ADD 0(IX) + LD B,A + + LD (FOG_COOR),BC + CALL CALC_ADR + DEC HL + INC DE + LD A,(HL) + OR A + JR Z,TURN_LOOP + + PUSH DE + LD (HL),#0 ; reveal fog of war + INC HL + CALL POINT + LD D,A ; inhoud adres + + LD BC,(FOG_COOR) + + LD A,C + LD C,B + LD B,A + SRL B + RR C + + CALL D_TO_POINT + + POP DE + JR TURN_LOOP + +FOG_COOR: .dw 0 + +CONT_TURNR: + LD A,11(IX) + AND #0b00000111 ; GEEN DRAAI HARV/COUNTER ATT + JP Z,AI_HARVB ; DE AI VAN DE BLAUWE HARV + + BIT 5,23(IX) + CALL NZ,TNK_CHK ; GUARD FUNCTIE VOOR ROOD ALLEEN + + LD A,(TURN_WAIT) + DEC A + LD (TURN_WAIT),A + RET NZ + + LD A,R + AND #0b00001111 + LD (TURN_WAIT),A + + LD A,9(IX) + LD B,A + + LD A,R ;refresh is random ?? + AND #0b00000011 ; yes!!! is coool + + OR A + RET Z + + CP #2 + JP Z,T_ROUND_DEC + + INC B + JP Z,UPDATE_TURN +T_ROUND_DEC: + DEC B + +UPDATE_TURN: + LD A,9(IX) + AND #0b10000000 + OR B ; fout correctie ! + AND #0b10000111 ; radar update bitje meenemen + LD 9(IX),A + RET + +TURN_WAIT: .db 10 + +;--------------------------------------------- + +DO_ATTACK: ; attack iets ?? + CALL SHOOT_GFX + + DEC 18(IX) + RET NZ + + BIT 3,11(IX) + JP NZ,DO_ATT_BLD + + LD L,13(IX) ; eigen nummer + + LD A,19(IX) ; wait time before shot + LD 18(IX),A + + LD A,14(IX) ; nummer van slachtoffer + LD (QUAKE),A ; + + LD H,16(IX) ; power + + LD E,20(IX) + LD D,21(IX) + + PUSH IX + CALL A_TO_IX + + LD A,4(IX) ; offset is niet 0 !!! + OR 5(IX) + JR NZ,STOP_ATTACK + + LD A,0(IX) + CP E + JR NZ,STOP_ATTACK + LD A,1(IX) + CP D + JR NZ,STOP_ATTACK + + ; attack kan ! + + LD A,H + SUB 17(IX) ; -shield + LD B,A + LD A,12(IX) ; power van QUAKE + SUB B + LD 12(IX),A + JR NC,CONT_ATTACK + + CALL REMOVE_TANK + POP IX + RET + +CONT_ATTACK: + SET 4,22(IX) ; voor inslag ani 0e frame + + ; BIT 5,23(IX) ; schiet nooit terug + ;JR NZ,CONTATTACK2 ; jajajaja dit werkt lekker + + LD 14(IX),L ; nummer degene die schiet + + LD A,11(IX) ; harvest filteren + AND #0b00000111 + JR Z,CONTATTACK3 + + RES 3,11(IX) ; reset attack build !!! + RES 4,11(IX) ; move uit + SET 5,11(IX) ; attack move aan + CALL TNK_CHK_HELP + +CONTATTACK2: + POP IX + SET 1,22(IX) ; voor schiet ani + RET +CONTATTACK3: + LD 14(IX),L + POP IX + SET 1,22(IX) + RET + +STOP_ATTACK: + LD A,13(IX) + POP IX + LD 14(IX),A + RES 6,11(IX) + SET 5,11(IX) + RET + +DO_ATT_BLD: + LD A,14(IX) + + CALL A_TO_BLD + + LD A,0(IY) ;geen gebouw + OR A + JR Z,STOP_ATT_B + + SET 1,22(IX) ; schiet ani + LD A,19(IX) ; wait time before shot + LD 18(IX),A + + LD A,16(IX) ;power TAnk + SUB 7(IY) ; -shield VAN GEBOUW + LD B,A + LD A,6(IY) ; power van GEBOUW + SUB B + LD 6(IY),A + JR Z,KILL_B + RET NC ; alles is goed schiet nog maar eens +KILL_B: + PUSH IX + CALL REMOVE_BUILD + POP IX +STOP_ATT_B: + RES 6,11(IX) ; kappe met schietn + RES 5,11(IX) + RET + + +;------------------------------------ + +SPEED_STEP: LD B,A + LD C,#0 + LD A,#16 +J8608: SUB B + JR Z,J860F + INC C + JP J8608 +J860F: LD 6(IX),C + + RET + +;-------------------------------------- +SHOOT_GFX: + LD A,22(IX) + AND #0b00000110 + OR A + RET Z + + LD IY,#IMPACT0 + SLA A + SLA A + SLA A + LD B,A + LD A,#144 + ADD B + LD 0(IY),A + + CALL COPY_SHOOT + + LD A,22(IX) + LD C,A + AND #0b11111001 + LD B,A + LD A,C + AND #0b00000110 + SRL A + INC A + AND #0b00000011 + SLA A + OR B + LD 22(IX),A + + RET + +IMPACT_GFX: + LD A,22(IX) + AND #0b00110000 + OR A + RET Z + + LD IY,#IMPACT0 + LD B,A + LD A,#192 + ADD B + LD 0(IY),A + + CALL COPY_SHOOT + + LD A,22(IX) + LD C,A + AND #0b11001111 + LD B,A + LD A,C + AND #0b00110000 + SRL A + SRL A + SRL A + SRL A + INC A + AND #0b00000011 + SLA A + SLA A + SLA A + SLA A + OR B + LD 22(IX),A + RET +COPY_SHOOT: + LD BC,(OFFSET) ; tank in veld ?? + LD A,0(IX) + SUB C + RET C + CP #10 + RET NC + + LD A,1(IX) + SUB B + RET C + CP #10 + RET NC + + EXX + LD HL,(OFFSET) + + LD A,0(IX) + SUB L + INC A + ADD A + ADD A + ADD A + ADD A + LD 4(IY),A + ; CP 16 + ; RET C + ; CP 161 + ; RET NC + + LD A,1(IX) + SUB H + INC A + ADD A + ADD A + ADD A + ADD A + LD 6(IY),A + ; CP 16 + ; RET C + ; CP 161 + ; RET NC + LD A,(SWAP) ; ??? waarom + LD 7(IY),A + CALL PUTBLK + EXX + RET + +;------------------------------------- +CHKUP: + LD H,D + LD L,E + + DEC H + JP CHK_ALL +CHKDN: + LD H,D + LD L,E + + INC H + JP CHK_ALL +CHKRI: + LD H,D + LD L,E + + LD BC,#4 + ADD HL,BC + JP CHK_ALL + +CHKLT: + LD H,D + LD L,E + + LD BC,#-4 + ADC HL,BC + JP CHK_ALL +CHKUPRI: + LD H,D + LD L,E + + DEC H + LD BC,#4 + ADD HL,BC + JP CHK_ALL + +CHKDORI: + LD H,D + LD L,E + + INC H + LD BC,#4 + ADD HL,BC + JP CHK_ALL + +CHKDOLT: + LD H,D + LD L,E + + INC H + LD BC,#-4 + ADC HL,BC + JP CHK_ALL + +CHKUPLT: + LD H,D + LD L,E + + DEC H + LD BC,#-4 + ADC HL,BC + +CHK_ALL: + LD A,(HL) + CP #80 + JP NC,RETURN_VAST +CHK_TANK_OBJ: + INC HL ; 2 byte van velddata + LD A,(HL) ; tank nummer + OR A + JP Z,RETURN_LOS +RETURN_VAST: + XOR A + OR A + RET +RETURN_LOS: + LD A,#1 + OR A + RET + +;------------------------------------------------ +; update het radar scherm en je money +;------------------------------------------------ +RADAR_UPDATE: + LD A,(RADAR) + INC A + AND #0b00000011 + LD (RADAR),A + CP #2 ; eens in de 4 keer + JR Z,MAKE_RAD_MON + JP NZ,SHOW_POWER + RET +MAKE_RAD_MON: + ; ; alle tanks even doorlopen + LD B,#254 + LD IX,#TANK1 + LD C,#TANK_DATA +MAKE_RAD_LP1: + LD A,13(IX) + OR A + JR Z,MAKE_RAD_END + + PUSH BC + + LD D,0(IX) + LD E,1(IX) + LD B,24(IX) + LD C,25(IX) + + LD A,D + CP B + JR NZ,MAKE_RAD_LP2 + + LD A,E + CP C + JR Z,MAKE_RAD_END2 +MAKE_RAD_LP2: + + CALL CALC_ADR + DEC HL + LD A,(HL) + OR A + JR NZ,MAKE_RAD_END3 + + INC HL + PUSH DE ; ligt aan CALC_ADR + CALL POINT + ; ; vlak in A + LD D,A + CALL PLACE_UNIT + + POP BC ; nieuwe coor in BC + LD 24(IX),B + LD 25(IX),C + + CALL CALC_ADR + DEC HL + LD A,(HL) + OR A + JR NZ,MAKE_RAD_END2 + + INC HL + CALL POINT2 + LD D,A + CALL PLACE_UNIT +MAKE_RAD_END2: + POP BC +MAKE_RAD_END: + LD A,B + LD B,#0 + ADD IX,BC + LD B,A + DJNZ MAKE_RAD_LP1 + RET +MAKE_RAD_END3: + + LD 24(IX),D + LD 25(IX),E + JR MAKE_RAD_END2 + +PLACE_UNIT: + LD C,24(IX) + LD B,25(IX) + SRL B + RR C +D_TO_POINT: + LD HL,#96 + ADD HL,BC ; hahyahah hihihiih lache he + + LD B,H + LD C,L + DI + LD A,#1 + CALL SETVDP2 + LD A,D + OUT (0x98),A ; oude positie weg + EI + LD H,B + LD L,C + DI + LD A,#3 + CALL SETVDP2 + LD A,D + OUT (0x98),A + EI + RET + +POINT: + LD A,L + AND #0b00000111 + CP #0b00000001 + JR NZ,POINT_R + + EX DE,HL + LD A,(DE) + + LD HL,#RAD_COL_TAB_L + SRL A + SRL A + SRL A + SRL A ; / 16 + LD C,A + LD B,#0 + ADD HL,BC ; adres + LD A,(HL) + EX AF,AF + + INC DE + INC DE + INC DE + LD A,(DE) + OR A + JR NZ,POINT_L_Z + + INC DE + LD A,(DE) + + LD HL,#RAD_COL_TAB_R + SRL A + SRL A + SRL A + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD D,(HL) + EX AF,AF + OR D + RET +POINT_L_Z: + LD D,#0 + EX AF,AF + OR D + RET +POINT_R: + EX DE,HL + LD A,(DE) + + LD HL,#RAD_COL_TAB_R + SRL A + SRL A + SRL A + SRL A ; / 16 + LD C,A + LD B,#0 + ADD HL,BC ; adres + LD A,(HL) + + EX AF,AF + + DEC DE + DEC DE + DEC DE + DEC DE + DEC DE + LD A,(DE) + OR A + JR NZ,POINT_R_Z + + INC DE + LD A,(DE) + + LD HL,#RAD_COL_TAB_L + SRL A + SRL A + SRL A + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD D,(HL) + EX AF,AF + OR D + RET +POINT_R_Z: + LD D,#0 + EX AF,AF + OR D + RET + +POINT2: + LD A,L + AND #0b00000111 + CP #0b00000001 + JR NZ,POINT2_R + + EX DE,HL + + LD A,13(IX) + CP #128 + JR C,POINT2_1 + LD A,#0b10100000 + JR POINT2_2 +POINT2_1: + LD A,#0b11010000 +POINT2_2: + EX AF,AF + + INC DE + INC DE + INC DE + LD A,(DE) + OR A + JR NZ,POINT2_L_Z + + INC DE + INC DE + LD A,(DE) + OR A + JR Z,POINT2_23 + CP #128 + JR C,POINT2_22 + + LD D,#0b00001010 + JR POINT2_24 +POINT2_22: + LD D,#0b00001101 + JR POINT2_24 +POINT2_23: + DEC DE + LD A,(DE) + LD HL,#RAD_COL_TAB_R + SRL A + SRL A + SRL A + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD D,(HL) +POINT2_24: + EX AF,AF + OR D + RET +POINT2_L_Z: + LD D,#0 + EX AF,AF + OR D + RET +POINT2_R: + EX DE,HL + LD A,13(IX) + CP #128 + JR C,POINT2_3 + LD A,#0b00001010 + JR POINT2_4 +POINT2_3: + LD A,#0b00001101 +POINT2_4: + EX AF,AF + + DEC DE + DEC DE + DEC DE + DEC DE + DEC DE + + LD A,(DE) + OR A + JR NZ,POINT2_R_Z + + INC DE + INC DE + LD A,(DE) + OR A + JR Z,POINT2_43 + CP #128 + JR C,POINT2_42 + + LD D,#0b10100000 + JR POINT2_44 +POINT2_42: + LD D,#0b11010000 + JR POINT2_44 +POINT2_43: + + DEC DE + LD A,(DE) + + LD HL,#RAD_COL_TAB_L + SRL A + SRL A + SRL A + SRL A + LD C,A + LD B,#0 + ADD HL,BC + LD D,(HL) +POINT2_44: + EX AF,AF + OR D + RET +POINT2_R_Z: + LD D,#0 + EX AF,AF + OR D + RET + +RAD_COL_TAB_R: + .db 0b00000001 + .db 0b00000010 + .db 0b00000011 + .db 0b00000100 + .db 0b00000100 + .db 0b00000101 + .db 0b00001101 + .db 0b00001101 + .db 0b00001010 + .db 0b00001010 + +RAD_COL_TAB_L: + .db 0b00010000 + .db 0b00100000 + .db 0b00110000 + .db 0b01000000 + .db 0b01000000 + .db 0b01010000 + .db 0b11010000 + .db 0b11010000 + .db 0b10100000 + .db 0b10100000 + + + +;------------------------------------ + +INIT_RADAR: LD DE,#VELD_ADRES + + LD HL,#96 + LD (VDPADR),HL + + LD A,#1 + CALL SETVDP + + LD B,#64 ; hoogte v.d. radar ? +J89B7: PUSH BC + LD B,#32 ; lengte + +J89BB: + LD A,(DE) + OR A + LD A,#0 + JR NZ,INIT_RADAR2 + + PUSH BC + PUSH DE + + INC DE + + EX DE,HL + CALL POINT + POP DE + POP BC +INIT_RADAR2: + OUT (0x98),A + + INC DE + INC DE + INC DE + INC DE + + INC DE + INC DE + INC DE + INC DE + + DJNZ J89BB + + LD HL,(VDPADR) + LD BC,#128 + ADD HL,BC + LD (VDPADR),HL + LD A,#1 + CALL SETVDP + + POP BC + DJNZ J89B7 + + LD HL,#0 + XOR A + CALL SETVDP + + LD IY,#RADCOP + CALL SPRITES_OFF + CALL PUTBLK + CALL SPRITES_ON + RET + +SETVDP: DI + OUT (0x99),A + LD A,#14 + SET 7,A + OUT (0x99),A + SET 6,H + RES 7,H + LD A,L + OUT (0x99),A + LD A,H + OUT (0x99),A + EI + RET + +SETVDP2: + OUT (0x99),A + LD A,#14 + SET 7,A + OUT (0x99),A + SET 6,H + RES 7,H + LD A,L + OUT (0x99),A + LD A,H + OUT (0x99),A + RET + + +;------------ BUILD ------------------- +; main build event +;-------------------------------------- + +BUILD: + ; XOR A + ; LD (0xFC9E),A + + LD A,(SWAP) + XOR #1 + LD (SWAP),A + + CALL VELD + CALL TANKS + CALL BUILD_SEL + + LD A,(ISTEXT) + OR A + CALL NZ,PUT_TEXT + + LD A,(SWAP) + ADD A ; dit schijnt sneller te zijn ! + ADD A ; DAN SLA, SLA ,SLA EN SLA SLA + ADD A + ADD A + ADD A + + ADD #31 + + DI ; nu altijd in int. dus ... + OUT (0x99),A + LD A,#2+128 + OUT (0x99),A + EI + RET + +BUILD_SEL: + LD A,(ITEMSELECTED) + CP #128 + RET C + + LD IX,(P_BUILD) + +BUILD_SEL1: + LD DE,(OFFSET) + + LD A,2(IX) + SUB E + SLA A + SLA A + SLA A + SLA A + ADD #16 + LD H,A + + LD A,3(IX) + SUB D + SLA A + SLA A + SLA A + SLA A + ADD #16 + LD L,A + + LD A,2(IX) + LD B,A + LD A,(OFFSET) + LD C,A + DEC A + CP B + JP NC,BUILD_SEL3 + ADD A,#10 + CP B + RET C + + LD A,3(IX) + LD B,A + LD A,(OFFSET+1) + LD C,A + DEC A + CP B + JP NC,BUILD_SEL2 + ADD A,#10 + CP B + RET C + + LD IY,#COP_BSEL_1 + LD 4(IY),H + LD 6(IY),L + EXX + CALL PUTBLK + EXX + +BUILD_SEL2: + LD A,3(IX) + ADD 5(IX) + DEC A + LD B,A + LD A,(OFFSET+1) + LD C,A + DEC A + CP B + RET NC + ADD A,#10 + CP B + JP C,BUILD_SEL3 + + LD IY,#COP_BSEL_2 + LD A,5(IX) + DEC A + SLA A + SLA A + SLA A + SLA A + ADD L + LD 4(IY),H + + LD 6(IY),A + EXX + CALL PUTBLK + EXX + +BUILD_SEL3: + LD A,2(IX) + ADD 4(IX) + DEC A + LD B,A + LD A,(OFFSET) + LD C,A + DEC A + CP B + RET NC + ADD A,#10 + CP B + RET C + + LD A,3(IX) + LD B,A + LD A,(OFFSET+1) + LD C,A + DEC A + CP B + JP NC,BUILD_SEL4 + ADD A,#10 + CP B + RET C + + LD IY,#COP_BSEL_3 + LD A,4(IX) + DEC A + SLA A + SLA A + SLA A + SLA A + ADD H + LD 4(IY),A + + LD 6(IY),L + EXX + CALL PUTBLK + EXX + + +BUILD_SEL4: + LD A,3(IX) + ADD 5(IX) + DEC A + LD B,A + LD A,(OFFSET+1) + LD C,A + DEC A + CP B + RET NC + ADD A,#10 + CP B + RET C + + LD IY,#COP_BSEL_4 + LD A,5(IX) + DEC A + SLA A + SLA A + SLA A + SLA A + ADD L + LD 6(IY),A + LD A,4(IX) + DEC A + SLA A + SLA A + SLA A + SLA A + ADD H + LD 4(IY),A + + EXX + JP PUTBLK + + RET + +TANKS: + LD IY,#TNKCOP + LD 2(IY),#160 + LD 10(IY),#16 + LD 8(IY),#16 + LD 0(IY),#0 + LD A,(SWAP) + LD 7(IY),A + + XOR A + LD (SELECTED),A + LD HL,#CPYTT + +FIELD_LOOP: ; ; eerst alles binnen kader + LD A,(HL) + OR A + JR Z,REMOVE_SPR ; klaar !!! + PUSH HL + CALL HL_TO_IX ; elke unit 1 keer +FIELD: + JP PTANK +IN_SCREEN: + POP HL + LD (HL),#3 ; binnen scherm voor ontplof tabel + + BIT 7,11(IX) + JR Z,J8C14 + + LD IX,#SPRATR+8 + LD A,4(IY) + LD 1(IX),A + LD A,6(IY) + LD 0(IX),A + EXX + CALL PUT_SPRITE + EXX + LD A,#1 + LD (SELECTED),A + JP J8C14 +CONT2: + POP HL +J8C14: + INC HL + INC HL + JP FIELD_LOOP + +REMOVE_SPR: LD A,(SELECTED) + OR A + JR NZ,RAND1 + + LD IX,#SPRATR+8 + LD 0(IX),#212 + CALL PUT_SPRITE + +RAND1: + LD HL,#CPYTT +RAND1_LOOP: + LD A,(HL) + OR A + JR Z,RAND2 + CP #2 + JR NC,RAND1_4 + + LD BC,(OFFSET) ; c=x & b=y + + CALL HL_TO_IX + LD A,C + SUB 0(IX) + JR Z,RAND1_6 + DEC A + JR NZ,RAND1_4 + + LD A,4(IX) ; mogelijkheid 3 check + BIT 7,A + JR NZ,RAND1_4 +RAND1_6: + + DEC C + DEC B + + LD A,0(IX) + SUB C + ADD A + ADD A + ADD A + ADD A ; x * 16 + LD C,A ; 0 v 16 + + LD A,1(IX) + SUB B + ADD A + ADD A + ADD A + ADD A + ADD 5(IX) + LD B,A ; y* 16 + offset + + LD A,4(IX) + OR A + JR Z,RAND1_4 ; positie 1 op 0 punt + CP #-16 + JR Z,RAND1_4 + + LD A,C + ADD 4(IX) + LD C,A + + LD A,B + CP #16 + JR C,RAND1_4 + CP #161 + JR NC,RAND1_4 + + PUSH HL + CALL PTANK_RI + POP HL + LD (HL),#2 +RAND1_4: + INC HL + INC HL + JP RAND1_LOOP + +RAND2: + LD HL,#CPYTT +RAND2_LOOP: + LD A,(HL) + OR A + JR Z,RAND3 + CP #2 + JR NC,RAND2_4 + + LD BC,(OFFSET) ; c=x & b=y + + CALL HL_TO_IX + LD A,B ; cp y offset + SUB 1(IX) + JR Z,RAND2_6 ; ligt ie binnen de randjes ! + DEC A + JR NZ,RAND2_4 + + LD A,5(IX) ; mogelijkheid 3 check + BIT 7,A + JR NZ,RAND2_4 +RAND2_6: + DEC C + DEC B + + LD A,0(IX) + SUB C + ADD A + ADD A + ADD A + ADD A ; x * 16 + OFFSET + ADD 4(IX) + LD C,A + + LD A,1(IX) + SUB B + ADD A + ADD A + ADD A + ADD A + LD B,A ; y* 16 + + LD A,5(IX) + OR A + JR Z,RAND2_4 ; positie 1 op 0 punt + CP #-16 + JR Z,RAND2_4 + + LD A,B + ADD 5(IX) + LD B,A + + LD A,C + CP #16 + JR C,RAND2_4 + CP #161 + JR NC,RAND2_4 + + PUSH HL + CALL PTANK_DN + POP HL + LD (HL),#2 +RAND2_4: + INC HL + INC HL + JP RAND2_LOOP + +RAND3: + LD HL,#CPYTT +RAND3_LOOP: + LD A,(HL) + OR A + JR Z,RAND4 + CP #2 + JR NC,RAND3_4 + + LD BC,(OFFSET) ; c=x & b=y + LD A,C + ADD #10 + LD C,A + + CALL HL_TO_IX + LD A,C + SUB 0(IX) + JR Z,RAND3_6 + DEC A + JR Z,RAND3_5 + JP RAND3_4 +RAND3_6: + LD A,4(IX) ; mogelijkheid 4 check + BIT 7,A + JR Z,RAND3_4 +RAND3_5: + DEC C + DEC B + + LD A,0(IX) + SUB C + ADD A + ADD A + ADD A + ADD A ; x * 16 + ADD #160 ; einde rand erbij + LD C,A ; 160 v 176 eruit + + LD A,1(IX) + SUB B + ADD A + ADD A + ADD A + ADD A + ADD 5(IX) + LD B,A ; y* 16 + offset + + LD A,4(IX) + OR A + JR Z,RAND3_4 ; positie 1 op 0 punt + CP #16 + JR Z,RAND3_4 + + LD A,C + ADD 4(IX) + LD C,A + + LD A,B + CP #16 + JR C,RAND3_4 + CP #161 + JR NC,RAND3_4 + + PUSH HL + CALL PTANK_LT + POP HL + LD (HL),#2 +RAND3_4: + INC HL + INC HL + JP RAND3_LOOP + +RAND4: + LD HL,#CPYTT +RAND4_LOOP: + LD A,(HL) + OR A + RET Z + CP #2 + JR NC,RAND4_4 + + LD BC,(OFFSET) ; c=x & b=y + LD A,B + ADD #10 + LD B,A + + CALL HL_TO_IX + LD A,B + SUB 1(IX) + JR Z,RAND4_6 + DEC A + JR Z,RAND4_5 + JP RAND4_4 +RAND4_6: + LD A,5(IX) ; mogelijkheid 4 check + BIT 7,A + JR Z,RAND4_4 +RAND4_5: + + DEC C + DEC B + + LD A,0(IX) + SUB C + ADD A + ADD A + ADD A + ADD A ; x * 16 +offset + ADD 4(IX) + LD C,A + + LD A,1(IX) + SUB B + ADD A + ADD A + ADD A + ADD A + ADD #160 + LD B,A ; y* 16 + offset + + LD A,5(IX) + OR A + JR Z,RAND4_4 ; positie 1 op 0 punt + CP #16 + JR Z,RAND4_4 + + LD A,B + ADD 5(IX) + LD B,A + + LD A,C + CP #16 + JR C,RAND4_4 + CP #161 + JR NC,RAND4_4 + + PUSH HL + CALL PTANK_UP + POP HL + LD (HL),#2 +RAND4_4: + INC HL + INC HL + JP RAND4_LOOP + +;------------------------------------- +; .include the AI.ASM ! + + .include "ai_new.asm" + +;----------------------------------- +; ALLERLEI ZOOI +;----------------------------------- + +ALGEMEEN: + CALL RED_DEAD + ; CALL PUT_MONEY + CALL PUT_FPS + CALL CHECK_BUILD + CALL UPDATE_STEPS + CALL MSELECTED + CALL REP_UPGR + CALL COMMANDO + +ONTPLOFFEN: + LD A,(PLOF_COUNT) + OR A + RET Z ; helemaal nix + + LD B,A + LD IX,#PLOF_TABEL-3 +LABEL0003: + INC IX + INC IX + INC IX + LD A,2(IX) + OR A + JR Z,LABEL0003 + EXX + CALL NZ,DOE_ONTPLOF + EXX + DJNZ LABEL0003 + RET ; geen ontploffingen ! + +DOE_ONTPLOF: + CP #11 + JR Z,ENDPLOF + LD IY,#PLOF_COP + ADD A + ADD A + ADD A + ADD A + LD 0(IY),A + + CALL PLOF_IN_RAND + LD A,B + OR A + JP Z,DOE_ONTPLOF2 + + LD HL,(OFFSET) + + LD A,0(IX) + SUB L + INC A + ADD A + ADD A + ADD A + ADD A + LD 4(IY),A + + LD A,1(IX) + SUB H + INC A + ADD A + ADD A + ADD A + ADD A + LD 6(IY),A + LD A,(SWAP) + LD 7(IY),A + CALL PUTBLK +DOE_ONTPLOF2: + INC 2(IX) + RET +ENDPLOF: + XOR A + LD 0(IX),A + LD 1(IX),A + LD 2(IX),A + LD A,(PLOF_COUNT) + DEC A + LD (PLOF_COUNT),A + RET + +PLOF_IN_RAND: + LD B,#0 + + LD HL,(OFFSET) + LD A,L + ADD A,#10 + LD E,A + LD A,H + ADD A,#10 + LD D,A + LD A,0(IX) + CP L + RET C + CP E + RET NC + LD A,1(IX) + CP H + RET C + CP D + RET NC + LD B,#1 + RET + +REP_UPGR: + LD IX,#BUILDING1 + LD C,#BUILD_DATA + LD B,#50 ; max +REPAIR_LOOP: + BIT 0,8(IX) + CALL NZ,DO_REPAIR + + BIT 1,8(IX) + CALL NZ,DO_UPGRADE + + LD A,B + LD B,#0 + ADD IX,BC + LD B,A + DJNZ REPAIR_LOOP + RET +DO_REPAIR: + INC 6(IX) + LD A,6(IX) + CP #255 + RET NZ + + RES 0,8(IX) + + CALL RES_MENU + RET + +DO_UPGRADE: + INC 11(IX) + LD A,11(IX) + OR A + RET NZ + + RES 1,8(IX) + CALL RES_MENU + + INC 9(IX) ; upgrade lev 1 up + + LD A,1(IX) + CP #7 ; yard is +1 upgrade + JR Z,UPGR_BBAR + + CP #4 + JR Z,UPGR_TBAR + + RET + +RES_MENU: + XOR A + LD (ACTIVE_MENU),A + PUSH IX + POP DE + LD HL,(P_BUILD) + SBC HL,DE + RET NZ + + PUSH BC + LD (P_BUILD),IX + CALL P_BLD_IMG ; reset build img + CALL COMMAND_B + LD IX,(P_BUILD) + POP BC ; terug in loop + RET + +UPGR_BBAR: + LD A,(UPG_LEV_BLD) + CP #3 + RET Z ; max upg lev bereikt + + EXX + PUSH IX + + INC A + LD (UPG_LEV_BLD),A + ADD #4 ; ???? + + ADD A ; *2 + ADD A ; *4 + LD C,A + LD B,#0 + LD HL,#BBB_VALUE + ADD HL,BC + LD (HL),#1 ; maak beschikbaar + + CALL INIT_BBAR + POP IX + EXX + + XOR A + LD (IS_BLD_UPGRADING),A + RET ; terug in loop + +UPGR_TBAR: + LD A,(UPG_LEV_UNT) + CP #4 + RET Z + + EXX + INC A + LD (UPG_LEV_UNT),A + + ADD A + ADD A + LD C,A + LD B,#0 + LD HL,#TBB_VALUE + ADD HL,BC + LD (HL),#1 + + PUSH IX + CALL INIT_BBAR + POP IX + EXX + XOR A + LD (IS_UNT_UPGRADING),A + RET + +MSELECTED: + LD A,(HAS_SELECT) + OR A + RET Z + + XOR A + LD (TOTAL_SELECT),A + + LD HL,(OFFSET) + + LD A,(SEL_X0) + SRL A + SRL A + SRL A + SRL A + ADD L + LD B,A ; X0 + + LD A,(SEL_X1) + SRL A + SRL A + SRL A + SRL A + ADD L + LD C,A ; X1 + + LD A,(SEL_Y0) + SRL A + SRL A + SRL A + SRL A + ADD H + LD D,A ; Y0 + + LD A,(SEL_Y2) + SRL A + SRL A + SRL A + SRL A + ADD H + LD E,A ; Y2 + + LD HL,#CPYTT +LOOP_MSEL: + LD A,(HL) + OR A + RET Z + CP #3 + JR NZ,LOOP_MSEL2 + + INC HL + LD A,(HL) + + PUSH HL + + CALL IN_MSEL + POP HL + INC HL + JR LOOP_MSEL +LOOP_MSEL2: + INC HL + INC HL + JR LOOP_MSEL + +IN_MSEL: + PUSH BC + CALL A_TO_IX + POP BC + + BIT 7,13(IX) ;type tank + RET NZ + + RES 0,22(IX) + + LD A,0(IX) + LD H,A + CP B + RET C + CP C + RET NC + LD A,1(IX) + LD L,A + CP D + RET C + CP E + RET NC + + LD A,(TOTAL_SELECT) + CP #25 + RET Z ; niet meer erbij ! + INC A + LD (TOTAL_SELECT),A + + LD A,#1 + LD (MSELECT_ON),A + + SET 0,22(IX) + RET + + +RED_DEAD: + LD A,(BLD_CNT_RED) + + + LD A,(CHK_RED_DEAD) + INC A + AND #0b00111111 + LD (CHK_RED_DEAD),A + RET NZ +CHK_RED: + LD HL,#TANKRED + LD BC,#13 + ADD HL,BC + LD DE,#TANK_DATA + LD B,#128 +LP_CHK_RED: + BIT 7,(HL) + RET NZ + ADD HL,DE + DJNZ LP_CHK_RED + LD A,#1 + LD (STOP),A + RET + +CHK_RED_DEAD: + .db 0 + +COMMANDO: + LD A,(MBUSY) + OR A + RET NZ + LD A,(ITEMSELECTED) + OR A + RET Z + + CP #127 + JR NC,COMM_BLD + + DEC A + JP Z,COMM_TNK_RED + DEC A + JR Z,COMM_HRV_RED + RET + +COMM_BLD: + CP #192 + RET NC ; geen rood gebouw + + LD HL,(P_BUILD) + LD BC,#8 + ADD HL,BC + + LD A,(ACTIVE_MENU) + BIT 0,(HL) + JR Z,COMM_BLD2 + LD IY,#MENU_RED_REP + LD B,#8 + CP B + JR NZ,COMM_BLD3 + RET +COMM_BLD2: + BIT 1,(HL) + RET Z + LD IY,#MENU_RED_UPG + LD B,#9 + CP B + RET Z +COMM_BLD3: + LD A,B + LD (ACTIVE_MENU),A + PUSH IY + CALL COMMAND_B + POP IY + JP PUTBLK + +COMM_HRV_RED: + LD HL,(TNKADR) + LD BC,#11 + ADD HL,BC + + LD A,(ACTIVE_MENU) + + BIT 4,(HL) + JR Z,COMM_HRV_RED2 + + EX AF,AF + LD BC,#15 + ADD HL,BC + LD A,(HL) + OR A + JR Z,COMM_HRV_RED1 + EX AF,AF + LD IY,#MENU_RED_RET + LD B,#11 + CP B + RET Z + JR COMM_HRV_RED3 +COMM_HRV_RED1: + EX AF,AF + LD IY,#MENU_RED_MOV + LD B,#4 + CP B + RET Z + JR COMM_HRV_RED3 +COMM_HRV_RED2: + LD BC,#11 + ADD HL,BC ; ix+22 + BIT 7,(HL) + JR Z,COMM_HRV_RED22 + LD IY,#MENU_RED_HRV + LD B,#10 ; 10 is harvsten menu + CP B + RET Z + JR COMM_HRV_RED3 + +COMM_HRV_RED22: + LD IY,#MENU_RED_STP + LD B,#1 + CP B + RET Z +COMM_HRV_RED3: + LD A,B + LD (ACTIVE_MENU),A + PUSH IY + CALL COMMAND_HARV + POP IY + JP PUTBLK + + +COMM_TNK_RED: + LD HL,(TNKADR) + LD BC,#11 + ADD HL,BC + + LD A,(ACTIVE_MENU) + + BIT 4,(HL) + JR Z,COMM_TNK_RED2 + LD IY,#MENU_RED_MOV + LD B,#4 + CP B + JR NZ,COMM_TNK_RED4 + RET + +COMM_TNK_RED2: + BIT 6,(HL) + JR Z,COMM_TNK_RED3 + LD IY,#MENU_RED_ATT + LD B,#6 + CP B + JR NZ,COMM_TNK_RED4 + RET +COMM_TNK_RED3: + LD IY,#MENU_RED_STP + LD B,#1 + CP B + RET Z +COMM_TNK_RED4: + LD A,B + LD (ACTIVE_MENU),A + PUSH IY + CALL COMMAND_TANK + POP IY + JP PUTBLK + +ACTIVE_MENU: + .db 0 + + +;---------------------------------------------- +; Check op bouwen gebouwen steps ?? +;-------------------------------------------- + +CHECK_BUILD: + LD HL,#BBB_VALUE + LD B,#18 ; max 18 was 13 +L_CHK_BUILD1: + PUSH BC + LD A,(HL) + CP #2 + CALL Z,CHECK_BUILD2 + CP #3 + CALL Z,READY_BUILD2 + + POP BC + INC HL + INC HL + INC HL + INC HL + DJNZ L_CHK_BUILD1 + RET + +CHECK_BUILD2: + LD A,B + CP #6 ; lager/gelijk aan 5 is AI + RET C + ; ; B-5 doen ? + + LD A,B ; correctie voor lus 13 + SUB #5 + LD B,A + + LD A,#14 ; max 13 + SUB B + LD B,A + + LD A,(B_BALK_TYPE) + OR A + LD A,(B_BALK_NR) + JR Z,CHECK_BUILD22 + LD A,(T_BALK_NR) ; is het visible ??? +CHECK_BUILD22: + CP B + RET NC + ADD A,#4 + CP B + RET C + + LD IY,#BB_STEPS_BAR + + SUB #4 + LD C,A + LD A,B + SUB C + ADD A + ADD A + ADD A + ADD A + ADD A + ADD #2 + LD 4(IY),A + + PUSH HL + INC HL + INC HL + LD A,(HL) + SRL A + SRL A + SRL A + + INC A + LD 10(IY),A + + CALL PUTBLK + LD A,7(IY) + XOR #1 + LD 7(IY),A + CALL PUTBLK + POP HL + RET + +READY_BUILD2: + LD A,B + CP #6 + JP C,AI_CREATE_CAR + + LD A,B ; hack correctie is weg te werken ! + SUB #5 + LD B,A + + EX AF,AF + LD A,B + CP #6 + LD A,(B_BALK_NR) + JR NC,READY_BUILD22 + + LD A,(T_BALK_NR) +READY_BUILD22: + LD E,A + LD (HL),#4 ; kan ook 3 zijn + + LD A,#13 ; building + tanks + SUB B + LD B,A + LD D,A + + INC B + + EX AF,AF + CP #6 + JR C,CREATE_CAR ; create car ook als niet vis + + LD A,(B_BALK_TYPE) + OR A + RET NZ ; if tbar visible then NOT + + LD A,E ; is het visible ??? + CP B + RET NC + ADD A,#4 + CP B + RET C + + LD C,E + LD A,B + SUB C + DEC A + ADD A + ADD A + ADD A + ADD A + ADD A + ADD #32 + LD E,A + + LD A,D + ADD A + ADD A + ADD A + ADD A + ADD A + LD D,A + + PUSH HL + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + LD IY,#BB_READY_COP + CALL PUTBLK + CALL P_BB_PART + POP HL + RET + +;----------------------------------------- +CREATE_CAR: + + LD C,E + LD A,B + SUB C + DEC A + ADD A + ADD A + ADD A + ADD A + ADD A + ADD #32 + LD E,A + + EX AF,AF + + LD A,D + LD (TYPE_OF_CAR),A + + PUSH HL ; push bb_bar adres + + LD HL,#BUILDING1 + INC HL + LD C,#BUILD_DATA + LD B,#25 ; 25 gebouwen van jou +LOOP_CRT_CAR: + PUSH HL + PUSH BC + LD A,(HL) + CP #4 ; gevonden ? dan createcar + CALL Z,CREATE_CAR2 + POP BC + POP HL + LD A,B + LD B,#0 + ADD HL,BC + LD B,A + DJNZ LOOP_CRT_CAR + + JR CANT_CREATE_TNK + RET ; mag eigenlijk niet hier komen + ; komt hier als geen enkele factory kan plaatsen +CREATE_CAR2: + ; ; if gevonden POP stack en cont + ; ; else RET + INC HL + LD B,(HL) ; ? + DEC B + INC HL + LD C,(HL) ; hoekje factory + + CALL CALC_ADR + + LD DE,#FACTORY_DEPLOY +CREATE_CAR2_LP: + LD A,(DE) + CP #100 + RET Z ; volgende factory + + PUSH HL + + LD A,(DE) + LD C,A + INC DE + LD A,(DE) + LD B,A + INC DE + ADD HL,BC + LD A,(HL) + CP #80 + JR NC,CREATE_CAR2_LP2 ; kan niet op rots of huis + INC HL + LD A,(HL) + OR A + JR NZ,CREATE_CAR2_LP2 ; kan niet op tank + JR CREATE_CAR3 +CREATE_CAR2_LP2: + POP HL + JR CREATE_CAR2_LP + RET ; probeer volgende factory + +CREATE_CAR3: + POP AF ; adres + POP AF ; stack + POP AF ; BC from 1st loop + POP AF ; building data + LD BC,#VELD_ADRES + SBC HL,BC + SRL L + SRL L + LD A,L + LD L,H + LD H,A + + LD A,(TYPE_OF_CAR) + LD D,A + LD A,#12 + SUB D + LD C,A + LD B,#1 ;blauw + CALL ADD_TANK + ; ; add tank kan ook fout gaan + OR A + JR Z,CANT_CREATE_TNK + + POP HL ; adres bb_bar + LD (HL),#1 ; clear tank bar + INC HL ; dit pas NA dat + LD A,(HL) ; de tank gebouwd is + INC HL + DEC A + LD (HL),A + + LD A,(B_BALK_TYPE) + OR A + RET Z + + LD A,(TYPE_OF_CAR) + SUB #8 + + ADD A + ADD A + ADD A + ADD A + ADD A + LD D,A + + EX AF,AF + OR A + RET Z + + LD E,A + + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + JP P_BB_PART + + RET + +CANT_CREATE_TNK: + ; ; bbar een stapje terug doen zodat ie + ; ; weer in de queue stapt + POP HL + + LD (HL),#2 + INC HL + LD A,#255 + SUB (HL) + INC HL + LD (HL),A + RET ; en even een message + + +TYPE_OF_CAR: .db 0 +;---------------------------------- +; check mouse na druk op knop +;---------------------------------- + +CHECK_COOR: + LD HL,#BUT_PRESSED + SET 0,(HL) + + LD DE,(MOUSEY) + + LD A,D + CP #16 + JR C,AREA3 + CP #176 + JR NC,AREA3 + LD A,E + CP #16 + JR C,AREA3 + CP #176 + JR NC,AREA3 + + LD A,#1 ; VOOR MSEL + LD (PLAYFIELD),A + + LD A,(MBUSY) ; doe commando + OR A + JP NZ,EXEC_COMMAND + + JP WHICH_OBJECT ; pak een tank + +AREA3: + XOR A + LD (PLAYFIELD),A + + LD A,D + CP #193 + JR C,AREA4 + CP #255 + JR NC,AREA4 + LD A,E + CP #128 + JR C,AREA4 + CP #192 + JR NC,AREA4 + + JP MOVE_RAD_SCR + +AREA4: LD A,D + CP #200 + JR C,AREA5 + CP #248 + JR NC,AREA5 + LD A,E + CP #16 + JR C,AREA5 + CP #104 + JR NC,AREA5 + + JP WHICH_ITEM +AREA5: + LD A,D + CP #32 + JR C,AREA51 + CP #160 + JR NC,AREA51 + LD A,E + CP #176 + JR C,AREA51 + + JP SEL_FROM_BB + +AREA51: + LD A,D + CP #16 + JR C,AREA6 + CP #32 + JR NC,AREA6 + LD A,E + CP #176 + JR C,AREA6 + CP #200 + JR NC,AREA6 + + JP SCRL_BB_L +AREA6: + LD A,D + CP #160 + JR C,AREA6A + CP #176 + JR NC,AREA6A + LD A,E + CP #176 + JR C,AREA6A + CP #200 + JR NC,AREA6A + + JP SCRL_BB_R + +AREA6A: + + LD A,D + CP #226 + JR C,AREA6B + CP #246 + JR NC,AREA6B + LD A,E + CP #192 + JR C,AREA6B + CP #200 + JR NC,AREA6B + JP SCRL_BB_UP +AREA6B: + LD A,D + CP #194 + JR C,AREA7 + CP #224 + JR NC,AREA7 + LD A,E + CP #192 + JR C,AREA7 + CP #200 + JR NC,AREA7 + JP SCRL_BB_DN + +AREA7: + LD A,D ; option + CP #80 + JR C,AREA8 + CP #128 + JR NC,AREA8 + LD A,E + CP #0 + JR C,AREA8 + CP #12 + JR NC,AREA8 + + JP OPTION_MENU + +AREA8: + LD A,D + CP #16 + JR C,AREA9 + CP #64 + JR NC,AREA9 + LD A,E + CP #0 + JR C,AREA9 + CP #12 + JR NC,AREA9 + + LD A,#1 + LD (STOP),A + RET + +AREA9: + RET + +;-------------------------------------------- + +WHICH_OBJECT: + CALL XYTO16 + LD B,D + LD C,E + CALL CALC_ADR + DEC HL + LD A,(HL) + OR A + RET NZ ; op onzichtbaar + INC HL + INC HL + LD A,(HL) + OR A + JP Z,WHICH_OBJCT2 ; geen tank !!! + + CALL A_TO_IX + LD B,13(IX) + + LD IY,(TNKADR) + LD A,13(IY) + CP B + RET Z ; dezelfde tank ! + + RES 7,11(IY) + + LD (TNKADR),IX + + CALL P_TNK_IMG + + BIT 7,13(IX) ; soort bit + JR NZ,ENEMY_SELTD + + LD A,#100 + LD (ISTEXT),A + LD A,R + AND #0b00000011 + CALL INIT_TEXT + + XOR A + LD (ACTIVE_MENU),A + + LD A,11(IX) + AND #0b00000111 + JR Z,HARV_SELTD + + LD A,#1 + LD (ITEMSELECTED),A + ; CALL COMMAND_TANK ;gebeurt al in COMMANDO + CALL SHOW_POWER + SET 7,11(IX) + RET +HARV_SELTD: + LD A,#2 + LD (ITEMSELECTED),A + ; CALL COMMAND_HARV + CALL SHOW_POWER + SET 7,11(IX) + RET + +ENEMY_SELTD: + LD A,#32 + LD (ITEMSELECTED),A + CALL COMMAND_ENM ; misschien cursor type reset + CALL SHOW_POWER + SET 7,11(IX) + RET ; klaar dus uit de loop + + +WHICH_OBJCT2: + DEC HL + LD A,(HL) + CP #96 + RET C + CP #160 + RET Z + + LD C,#7 ; yard + CP #100 + JR C,LOOP0_OBJCT2 + + LD C,#1 ; windtrap + CP #104 + JR C,LOOP0_OBJCT2 + + LD C,#2 ; ref + CP #110 + JR C,LOOP0_OBJCT2 + + LD C,#5 ; radar + CP #114 + JR C,LOOP0_OBJCT2 + + LD C,#3 ; silo + CP #118 + JR C,LOOP0_OBJCT2 + + LD C,#4 + CP #124 + JR C,LOOP0_OBJCT2 + + + LD C,#7 + CP #132 + JR C,LOOP1_OBJCT2 + + LD C,#1 + CP #136 + JR C,LOOP1_OBJCT2 + LD C,#4 + CP #156 + JR C,LOOP1_OBJCT2 + RET + +LOOP0_OBJCT2: + LD IX,#BUILDING1 + LD B,#25 ; 25 blauwe + LD H,#128 ; voor itemselected + JP LOOP0_OBJ2 +LOOP1_OBJCT2: + LD IX,#BUILDING1+24*BUILD_DATA + LD H,#192 ; itemsel + LD B,#25 ; 25 x rood +LOOP0_OBJ2: + PUSH BC + + LD A,1(IX) + CP C + JR NZ,LOOP0_OBJ21 + + LD A,2(IX) + DEC A + CP D + JR NC,LOOP0_OBJ21 + + ADD 4(IX) + CP D + JR C,LOOP0_OBJ21 + + LD A,3(IX) + DEC A + CP E + JR NC,LOOP0_OBJ21 + + ADD 5(IX) + CP E + JR C,LOOP0_OBJ21 + + LD IY,(TNKADR) + RES 7,11(IY) + + LD (P_BUILD),IX + + LD A,H ; itemselected = 128 + c ??? + ADD C ; YARD is 128 + LD (ITEMSELECTED),A + + CP #191 + JR NC,ENEMY_BUILD + + CALL COMMAND_B + JR LAB0023 +ENEMY_BUILD: + CALL COMMAND_ENM ; misschien cursor type reset +LAB0023: + CALL P_BLD_IMG + CALL SHOW_POWER + POP BC + + LD HL,#TANKTAB ; tnkadr resetten op 0 + LD (TNKADR),HL + XOR A + LD (ACTIVE_MENU),A + RET ; building gevonden !!! + + +LOOP0_OBJ21: + LD BC,#BUILD_DATA + ADD IX,BC + POP BC + DJNZ LOOP0_OBJ2 + + RET + +;----------------------------------------- +; PUT TANK IMAGE +;------------------------------------------- + +P_TNK_IMG: + LD IY,#GRAY_ITEM + CALL PUTBLK + + LD IY,#TANK_IMG + LD A,11(IX) + AND #0b00000111 + LD B,A + LD A,#4 + SUB B + ADD A + ADD A + ADD A + ADD A + ADD A + + LD 0(IY),A + CALL PUTBLK + + LD IY,#PUT_ITEM + LD 7(IY),#0 + CALL PUTBLK + LD 7(IY),#1 + CALL PUTBLK + RET + +;----------------------------------------- +; PUT BUILDING IMAGE +;------------------------------------------- + +P_BLD_IMG: + LD IY,#GRAY_ITEM + CALL PUTBLK + + LD IY,#BUILD_IMG + LD A,1(IX) + ADD A + ADD A + ADD A + ADD A + ADD A + LD 0(IY),A + CALL PUTBLK + + LD IY,#PUT_ITEM + LD 7(IY),#0 + CALL PUTBLK + LD 7(IY),#1 + CALL PUTBLK + RET + +;------------------------------------------------- +MOVE_RAD_SCR: ; + LD IX,#SPRATR+4 + LD HL,#VELD_ADRES+260 ;ADR+193 !!! + + LD A,D + CP #246 + JR C,MOV_RAD_SCR1 + + LD A,#245 +MOV_RAD_SCR1: LD 1(IX),A + SUB #193 + LD C,A + INC A + LD (OFFSET),A + + SLA C + SLA C + + LD B,#0 + ADD HL,BC + + LD A,E + CP #181 + JR C,MOV_RAD_SCR2 + + LD A,#180 +MOV_RAD_SCR2: LD 0(IX),A + SUB #128 + LD C,A + INC A + LD (OFFSET+1),A + LD B,C + LD C,#0 + ADD HL,BC + LD BC,(ADR) + LD (ADR),HL + + XOR A + SBC HL,BC + RET Z + + CALL PUT_SPRITE + JP BUILD ; om ontploffen niet buiten build om +;------------------------------------ + +WHICH_ITEM: LD A,(MBUSY) + OR A + JP NZ,CHK_CANCEL + + LD A,(ITEMSELECTED) + OR A + RET Z + CP #191 ; enemy building + RET NC + + CP #64 ; bb bar + JR NC,BUILDING_COM + CP #31 ; geen enemy of gebouw ?? + RET NC + CP #2 ; eigen harv + JR Z,HARV_COMMAND + +TANK_COMMAND: + LD A,E + CP #96 + JR NC,TANK_CANCEL ; moet eigenlijk stop zijn !! + CP #88 + JR NC,TANK_GUARD + CP #80 + JP NC,TANK_MOVE + CP #72 + JP NC,TANK_ATTACK + RET + +HARV_COMMAND: + LD A,E + CP #96 + JP NC,HARV_RETURN ; return ! + CP #88 + JR NC,TANK_GUARD ; stop ! + CP #80 + JP NC,TANK_MOVE ; gewoon een move + CP #72 + JR NC,TANK_ATTACK ; wordt opgevat als harvest + RET + +BUILDING_COM: + LD A,E + CP #96 + JP NC,BUILD_CANCEL + CP #88 + RET NC + CP #80 + JP NC,BUILD_UPGR + CP #72 + JP NC,BUILD_REP + + RET + +CHK_CANCEL: + LD A,E + CP #96 + RET C +CHK_CANCEL2: + + LD A,(ITEMSELECTED) + OR A + RET Z + CP #64 + JR NC,CANCEL_BB + CP #31 ; enemy selected geen cancel + RET NC + CP #2 + JR Z,CANCEL_HARV + +CANCEL_TANK: + XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + CALL COMMAND_TANK + RET + +CANCEL_HARV: + XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + CALL COMMAND_HARV ; command harv!! + RET + +CANCEL_BB: + XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + LD (ITEMSELECTED),A + CALL CLEAR_ITEM + JP BB_CANCEL + +TANK_CANCEL: + CALL CLEAR_ITEM + + LD IX,(TNKADR) + RES 7,11(IX) + LD HL,#TANKTAB + LD (TNKADR),HL + RET + +TANK_GUARD: LD IX,(TNKADR) + LD A,0(IX) + LD 2(IX),A + LD A,1(IX) + LD 3(IX),A + RES 5,11(IX) + RES 6,11(IX) + RES 7,22(IX) ;eigenlijk alleen voor harvesters :) + RET + +TANK_ATTACK: + CALL CANCEL_ITEM + LD A,#2 + LD (MBUSY),A + LD A,#28 + LD (CURSOR_TYPE),A + RET + +TANK_MOVE: + CALL CANCEL_ITEM + LD A,#1 + LD (MBUSY),A + LD A,#28 + LD (CURSOR_TYPE),A + RET + +EXEC_COMMAND: + XOR A + LD (ACTIVE_MENU),A + LD A,(ITEMSELECTED) + CP #1 + JR Z,TNK_COMMAND + CP #2 + JR Z,HRV_COMMAND + CP #128 ; gebouw geselecteerd ?? + RET NC + + CP #64 ; alles tussen 64 - 128 + JP NC,BB_COMMAND + RET ; enemy + +HRV_COMMAND: + LD A,(MBUSY) + CP #1 + JR Z,TNK_COM_MOVE + CP #2 + JP Z,HRV_COM_HRV + RET + +TNK_COMMAND: LD A,(MBUSY) + CP #1 + JR Z,TNK_COM_MOVE + CP #2 + JR Z,TNK_COM_ATT + RET + + +TNK_COM_MOVE: CALL XYTO16 + LD IX,(TNKADR) + LD 2(IX),D + LD 3(IX),E + RES 5,11(IX) + RES 6,11(IX) + RES 7,22(IX) ;harvest bitje uit + XOR A + LD 26(IX),A ; harvest wachttijd uit + + LD A,(MSELECT_ON) + OR A + CALL NZ,MOVE_MSEL + + LD A,(ITEMSELECTED) + CP #1 + CALL Z,COMMAND_TANK + CP #2 + CALL Z,COMMAND_HARV + + XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + RET + +MOVE_MSEL: + BIT 0,22(IX) + RET Z + + LD A,#127 ; tanksum + LD BC,#TANK_DATA + LD IX,#TANK1 + LD IY,#DEST_OFFSET +LP_MOVE_MSEL: + BIT 0,22(IX) + CALL NZ,DO_SEL_MOVE + ADD IX,BC + DEC A + RET Z + JP LP_MOVE_MSEL + +DO_SEL_MOVE: + EX AF,AF + LD A,0(IY) + ADD A,D + LD 2(IX),A + LD A,1(IY) + ADD A,E + LD 3(IX),A + INC IY + INC IY + EX AF,AF + RES 5,11(IX) + RES 6,11(IX) + RES 7,22(IX) ;harvest bitje uit + RET + +TNK_COM_ATT: + LD IX,(TNKADR) + RES 6,11(IX) + + CALL XYTO16 + LD B,D + LD C,E + CALL CALC_ADR + + LD A,(HL) + CP #80 + JR C,TNK_COM_ATT2 + CP #144 + JR NC,TNK_COM_ATT2 + JP TNK_ATT_BLD + +TNK_COM_ATT2: + INC HL + + LD A,(HL) ; geen rooie + CP #128 + RET C + + LD 14(IX),A ; nummer enemy tank + + RES 3,11(IX) ; je valt een tank aan + SET 5,11(IX) + LD 2(IX),D ; x en y van enemy + LD 3(IX),E + + LD A,(MSELECT_ON) ; multiple select attack + OR A + CALL NZ,ATT_MSEL + +J8895: XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + + CALL COMMAND_TANK + + RET + +ATT_MSEL: + BIT 0,22(IX) + RET Z + + LD B,#127 ; tnksum + LD C,#TANK_DATA + LD IX,#TANK1 +LP_ATT_MSEL: + BIT 0,22(IX) + CALL NZ,DO_SEL_ATT + LD A,B + LD B,#0 + ADD IX,BC + LD B,A + DJNZ LP_ATT_MSEL + RET +DO_SEL_ATT: + ; zorg dat de harvesters niet in ATTSEL zitten !!! + LD A,11(IX) + AND #0b00000111 + OR #0 + RET Z + + RES 3,11(IX) + SET 5,11(IX) + LD 2(IX),D + LD 3(IX),E + LD A,(HL) + LD 14(IX),A + RET + +TNK_ATT_BLD: + SET 3,11(IX) ;ATT BUILDING + SET 5,11(IX) + LD 2(IX),D + LD 3(IX),E ; rij erheen + + LD IY,#BUILDING1 + LD B,#50 ; 50 blauwe +LOOP1_OBJ2: + PUSH BC + + LD A,2(IY) + DEC A + CP D + JR NC,LOOP1_OBJ21 + + ADD 4(IY) + CP D + JR C,LOOP1_OBJ21 + + LD A,3(IY) + DEC A + CP E + JR NC,LOOP1_OBJ21 + + ADD 5(IY) + CP E + JR C,LOOP1_OBJ21 + + POP BC + LD H,0(IY) ;nummer gebouw + LD 14(IX),H + + LD A,(MSELECT_ON) ; multiple select attack + OR A ; on building + CALL NZ,ATT_MSEL2 + + JP J8895 ; menu goed +LOOP1_OBJ21: + LD BC,#BUILD_DATA + ADD IY,BC + POP BC + DJNZ LOOP1_OBJ2 + + RET ; als het goed is komt ie hier nooit ! + +ATT_MSEL2: + BIT 0,22(IX) + RET Z + + LD IX,#TANK1 + + LD B,#127 ; tnksum + LD C,#TANK_DATA +LP_ATT_MSEL2: + BIT 0,22(IX) + CALL NZ,DO_SEL_ATT2 + LD A,B + LD B,#0 + ADD IX,BC + LD B,A + DJNZ LP_ATT_MSEL2 + RET +DO_SEL_ATT2: + ;zorg dat de harvesters niet in ATTSEL zitten !!! + LD A,11(IX) + AND #0b00000111 + OR #0 + RET Z + + SET 3,11(IX) + SET 5,11(IX) + LD 2(IX),D + LD 3(IX),E + LD 14(IX),H + RET + +;---------------------------------- +HRV_COM_HRV: + CALL XYTO16 + PUSH DE + LD B,D + LD C,E + CALL CALC_ADR + POP DE + LD A,(HL) + + CP #16 + RET C + CP #48 + RET NC + + LD IX,(TNKADR) + LD 2(IX),D + LD 3(IX),E + SET 7,22(IX) + + CALL COMMAND_HARV + XOR A + LD (MBUSY),A + LD (CURSOR_TYPE),A + + RET + +HARV_RETURN: + LD A,#50 ; timer wait bij refinery + LD 26(IX),A + LD IX,(TNKADR) +HARV_RETURN2: + + LD HL,#BUILDING1 + INC HL + LD DE,#BUILD_DATA + LD B,#25 ; max +HARV_R_LOOP: + LD A,(HL) + CP #2 + JR Z,HARV_RET2 +HARV_R_LOOP2: + ADD HL,DE + DJNZ HARV_R_LOOP + RET +HARV_RET2: + PUSH HL + POP IY + LD A,11(IY) ; eigenlijk ix+12 :) = bezet byte + OR A + JR NZ,HARV_R_LOOP2 + LD 11(IY),#1 + + INC HL + LD A,(HL) + ADD #3 + + LD 2(IX),A + INC HL + LD A,(HL) + ADD #2 + LD 3(IX),A + RET + +BUILD_REP: + LD IX,(P_BUILD) + LD A,6(IX) + INC A + RET Z + BIT 1,8(IX) + RET NZ + SET 0,8(IX) + RET +BUILD_UPGR: + LD IX,(P_BUILD) + LD A,10(IX) + SUB 9(IX) + RET Z + BIT 0,8(IX) ; repair is busy + RET NZ + + LD A,1(IX) + CP #7 + JR Z,BUILD_UPGR2 + + LD A,(IS_UNT_UPGRADING) + OR A + RET NZ + SET 1,8(IX) + LD A,#1 + LD (IS_UNT_UPGRADING),A + RET +BUILD_UPGR2: + LD A,(IS_BLD_UPGRADING) + OR A + RET NZ + SET 1,8(IX) + LD A,#1 + LD (IS_BLD_UPGRADING),A + RET + +BUILD_CANCEL: + LD HL,#BUT_PRESSED + BIT 0,(HL) + RET NZ + + LD IX,(P_BUILD) + BIT 0,8(IX) + JR NZ,BUILD_CANCEL3 + + BIT 1,8(IX) + JR NZ,BUILD_CANCEL2 + JP CLEAR_ITEM +BUILD_CANCEL2: + RES 1,8(IX) + LD 11(IX),#0 ; upgrade lev op 0 + LD A,1(IX) + CP #7 + JR Z,BUILD_CANCEL4 + XOR A + LD (IS_UNT_UPGRADING),A + JR BUILD_CANCEL3 +BUILD_CANCEL4: + XOR A + LD (IS_BLD_UPGRADING),A +BUILD_CANCEL3: + RES 0,8(IX) + SET 0,(HL) + XOR A + LD (ACTIVE_MENU),A + CALL COMMAND_B + RET + + +;--------------------------------------- +BB_COMMAND: + LD A,(BB_BLOCKED) + OR A + RET NZ + + LD A,(ITEMSELECTED) + CP #64 + JR Z,P_BETON + + CP #65 + JP Z,P_WINDTRAP + + CP #66 + JP Z,P_REFINERY + + CP #67 + JP Z,P_SILO + + CP #68 + JP Z,P_FACTORY + + CP #69 + JP Z,P_RADAR + + RET + +P_BETON: + CALL XYTO16 + LD B,D + LD C,E + CALL CALC_ADR + + LD (HL),#64 ; danbeton erop + + JP RESET_STATUS + +P_CONST_Y: + ; to be done + RET + +P_REFINERY: + CALL XYTO16 + + PUSH DE + + LD H,#2 ; refinery is 3 + CALL ADD_BUILDING + POP DE + OR A + RET Z ; building vol + + LD B,D + LD C,E + CALL CALC_ADR + + CALL NO_BETON_CHK + LD (HL),#104 ; refinery erop + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#105 + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#106 + INC H + CALL NO_BETON_CHK + LD (HL),#109 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#108 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#107 + + LD L,E + INC L + LD H,D + INC H + INC H + LD B,#1 + LD C,#0 + CALL ADD_TANK + + JP RESET_STATUS +P_FACTORY: + CALL XYTO16 + PUSH DE + + LD H,#4 + CALL ADD_BUILDING + POP DE + OR A + RET Z ; max. bereikt + + LD A,(UPG_LEV_UNT) + LD 9(IX),A + + + LD B,D + LD C,E + CALL CALC_ADR + + CALL NO_BETON_CHK + LD (HL),#118 ; refinery erop + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#119 + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#120 + INC H + CALL NO_BETON_CHK + LD (HL),#123 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#122 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#121 + + ; ; Maak de eerste unit beschikbaar + + LD HL,#TBB_VALUE + LD (HL),#1 + + JP RESET_STATUS + +P_RADAR: + CALL XYTO16 + + PUSH DE + + LD H,#5 ; radar is 4 + CALL ADD_BUILDING + POP DE + OR A + RET Z ; building vol + + LD B,D + LD C,E + CALL CALC_ADR + + CALL NO_BETON_CHK + LD (HL),#110 ; windtrap erop + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#111 + INC H + CALL NO_BETON_CHK + LD (HL),#113 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#112 + JP RESET_STATUS + +P_SILO: + CALL XYTO16 + + PUSH DE + + LD H,#3 ; silo is 5 + CALL ADD_BUILDING + POP DE + OR A + RET Z ; building vol + + LD B,D + LD C,E + CALL CALC_ADR + + CALL NO_BETON_CHK + LD (HL),#114 ; windtrap erop + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#115 + INC H + CALL NO_BETON_CHK + LD (HL),#117 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#116 + JP RESET_STATUS + +P_WINDTRAP: + CALL XYTO16 + + PUSH DE + + LD H,#1 ; windtrap is 2 + CALL ADD_BUILDING + POP DE + OR A + RET Z ; building vol + + LD B,D + LD C,E + CALL CALC_ADR + + CALL NO_BETON_CHK + LD (HL),#100 ; windtrap erop + INC HL + INC HL + INC HL + INC HL + CALL NO_BETON_CHK + LD (HL),#101 + INC H + CALL NO_BETON_CHK + LD (HL),#103 + DEC HL + DEC HL + DEC HL + DEC HL + CALL NO_BETON_CHK + LD (HL),#102 + JP RESET_STATUS + +ADD_BUILDING: + LD A,(BUILDINGS) ; jammer niet meer + CP #50 ; dan 10 stuks !! + LD A,#0 + RET Z ; voor de veiligheid + + LD IX,#BUILDING1 + LD BC,#BUILD_DATA ; even loopen + LD A,#50 ; max 50 stuks + LD L,A +LOOP_ADD_B: + LD A,0(IX) + OR A + JR Z,ADD_BUILD2 + + LD (BUILD_NUM),A + + ADD IX,BC + DEC L + JR NZ,LOOP_ADD_B + RET + +BUILD_NUM: .db 0 + +ADD_BUILD2: + LD A,(BUILD_NUM) + INC A + LD 0(IX),A ; nummer vorige + 1 + LD A,H ;type gebouw + LD 1(IX),A + LD 2(IX),D + LD 3(IX),E + EXX + ; bewaar info per huisje + ; anders + LD HL,#EXTR_B_DATA + LD B,#0 + LD C,A + SLA C + SLA C + SLA C + ADD HL,BC + + PUSH IX + POP DE ; DE is dest. + INC DE ; num + INC DE ; type + INC DE ; x + INC DE ; y + LD BC,#8 + + LDIR ; pompen of verzuipen ! + + EXX + LD HL,#BUILDINGS + INC (HL) + LD A,#1 ; gebouw is goed toegevoegd + + RET + +NO_BETON_CHK: + LD A,(HL) + CP #64 + RET Z + LD A,6(IX) + SUB #32 + LD 6(IX),A + RET + +RESET_STATUS: + LD A,(ITEMSELECTED) + SUB #64 + LD D,A + + LD HL,#BBB_VALUE + SLA A + SLA A + LD C,A + LD B,#0 + ADD HL,BC + LD (HL),#1 ; maak weer beschikbaar + INC HL + LD A,(HL) + + INC HL + DEC A + LD (HL),A + + INC D ; correctie voor berekening + + LD A,(B_BALK_NR) + LD E,A + CP D + JR NC,RESETSTATUS2 + ADD A,#4 + CP D + JR C,RESETSTATUS2 + SUB #4 + + DEC D + LD A,D + SUB E + ADD A + ADD A + ADD A + ADD A + ADD A + ADD #32 + LD E,A + + LD A,D + ADD A + ADD A + ADD A + ADD A + ADD A + LD D,A + + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + CALL P_BB_PART +RESETSTATUS2: + JP CANCEL_BB + +;--------------------------------------- + +CANCELACTION: + LD HL,#BUT_PRESSED + BIT 1,(HL) + RET NZ + SET 1,(HL) + + LD A,(MSELECT_ON) + OR A + CALL NZ,MSEL_OFF + + LD A,(MBUSY) + OR A + JP NZ,CHK_CANCEL2 + + LD A,(ITEMSELECTED) + OR A + RET Z + + CALL CLEAR_ITEM + + LD IX,(TNKADR) + RES 7,11(IX) + LD HL,#TANKTAB + LD (TNKADR),HL ; ook voor gebouwen ? + LD HL,#0 + LD (P_BUILD),HL ; ja dus + RET + +MSEL_OFF: + LD HL,#TANK1 + LD BC,#22 ;BYTE 22 + ADD HL,BC + + LD B,#127 ;tank sum + LD DE,#TANK_DATA +CANCEL_LOOP: + RES 0,(HL) + ADD HL,DE + DJNZ CANCEL_LOOP + RET + +;----------------------------------------- +BB_CANCEL: + LD BC,#4 + LD HL,#SPRATR+16 + LD (HL),#212 + ADD HL,BC + LD (HL),#212 + ADD HL,BC + LD (HL),#212 + ADD HL,BC + LD (HL),#212 + ADD HL,BC + LD (HL),#212 + ADD HL,BC + LD (HL),#212 + + DI + LD A,#1 + OUT (0x99),A + LD A,#0x8E + + OUT (0x99),A + LD A,#0x10 + OUT (0x99),A + LD A,#0x76 + OUT (0x99),A + + LD HL,#SPRATR+16 + LD BC,#0x1898 + OTIR + EI + RET + +;--------------------------------------- +; Build Balk commando +;--------------------------------------- +SCRL_BB_L: + LD A,(BB_WAIT) + OR A + RET NZ + + LD A,(B_BALK_TYPE) + OR A + JR Z,SCRL_BBB_L + + LD A,(T_BALK_NR) + CP #8 + RET Z + DEC A + LD (T_BALK_NR),A + JP INIT_BBAR + +SCRL_BBB_L: + LD A,(B_BALK_NR) + OR A + RET Z + DEC A + LD (B_BALK_NR),A + JP INIT_BBAR + +SCRL_BB_R: + LD A,(BB_WAIT) + OR A + RET NZ + + LD A,(B_BALK_TYPE) + OR A + JR Z,SCRL_BBB_R + + LD A,(T_BALK_NR) + CP #9 + RET Z + INC A + LD (T_BALK_NR),A + JP INIT_BBAR +SCRL_BBB_R: + LD A,(B_BALK_NR) + CP #4 + RET Z + INC A + LD (B_BALK_NR),A + JP INIT_BBAR + +SCRL_BB_UP: + LD A,(BB_WAIT) + OR A + RET NZ + + LD A,(B_BALK_TYPE) + CP #0 + RET Z + + LD A,#0 + LD (B_BALK_TYPE),A + JP INIT_BBAR + +SCRL_BB_DN: + LD A,(BB_WAIT) + OR A + RET NZ + + LD A,(B_BALK_TYPE) + CP #32 + RET Z + LD A,#32 + LD (B_BALK_TYPE),A + +INIT_BBAR: + LD A,#6 + LD (BB_WAIT),A + + LD A,(B_BALK_TYPE) + OR A + JR Z,PLACE_BBAR +PLACE_TBAR: + CALL SPRITES_OFF + LD HL,#TBB_VALUE + + LD A,(T_BALK_NR) + SUB #8 ; start op 9 + + ADD A + ADD A + LD C,A + LD B,#0 + ADD HL,BC ; begin van tbb_valuelijst + + ADD A + ADD A + ADD A + LD D,A + + CALL INIT_LOOP_BB + + RET +PLACE_BBAR: + CALL SPRITES_OFF + + LD HL,#BBB_VALUE + + LD A,(B_BALK_NR) + + ADD A ; * 4 + ADD A + + LD C,A + LD B,#0 + ADD HL,BC + + ADD A + ADD A + ADD A + LD D,A + + +INIT_LOOP_BB: + LD B,#4 ; aantal plaatjes + LD E,#32 ; plaats op scherm +LOOP_P_BBAR0: + PUSH BC + PUSH HL + LD A,(HL) + + CP #0 + JP Z,P_BB_EMPTY + + CP #1 + JP Z,P_BB_OCC + + CP #2 + JP Z,P_BB_BUSY + + JP P_BB_READY + +END_LOOP_BB: + POP HL + POP BC + LD A,E + ADD #32 + LD E,A + + LD A,D + ADD #32 +END_LOOPBB3: + LD D,A + INC HL + INC HL + INC HL + INC HL + DJNZ LOOP_P_BBAR0 + CALL SPRITES_ON + + RET + +P_BB_EMPTY: + LD IY,#BB_X_COP + CALL PUTBLK + CALL P_BB_PART + JP END_LOOP_BB + +P_BB_OCC: + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + CALL P_BB_PART + JP END_LOOP_BB + +P_BB_BUSY: + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + LD IY,#BB_BUSY_COP + CALL PUTBLK + CALL P_BB_PART + JP END_LOOP_BB +P_BB_READY: + LD IY,#BB_BLW_COP + CALL PUTBLK + CALL BB_PUT_BUILD + LD IY,#BB_READY_COP + CALL PUTBLK + CALL P_BB_PART + JP END_LOOP_BB + +BB_PUT_BUILD: + ; ; check if tank bar + LD A,(B_BALK_TYPE) + OR A + JR Z,BB_PUT_BUILD2 +BB_PUT_TANK2: + LD IY,#BB_TNK_COP + LD A,D + LD 0(IY),A + JP PUTBLK +BB_PUT_BUILD2: + LD IY,#BB_BLD_COP + LD A,D + ; ADD 32 + LD 0(IY),A + + JP PUTBLK + +P_BB_PART: + LD IY,#BB_MOVE_COP + LD 4(IY),E ; plek op scherm + LD 7(IY),#0 + CALL PUTBLK + LD 7(IY),#1 + CALL PUTBLK + RET + +;------------------------------------------- + +SEL_FROM_BB: + LD A,(MBUSY) + OR A + RET NZ + + LD A,(B_BALK_TYPE) + OR A + JR Z,SEL_BUILDING + + LD A,D + SUB #32 + SRA A + SRA A + SRA A + SRA A + SRA A ; / 32 + LD B,A + + LD A,(T_BALK_NR) + SUB #8 + ADD B + LD E,A + + ADD A ; * 4 + ADD A ; + + LD C,A + + LD B,#0 + LD HL,#TBB_VALUE + ADD HL,BC + + LD A,(HL) + OR A ; niet mogelijk + RET Z + CP #2 ; al bezig + RET Z + CP #1 ; ga beginnen + JP Z,START_BUILD + + RET + RET +SEL_BUILDING: + LD A,D + SUB #32 + SRA A + SRA A + SRA A + SRA A + SRA A ; / 32 + LD B,A + + LD A,(B_BALK_NR) + ADD B + LD E,A + + ADD A ; * 4 + ADD A ; + + LD C,A + + LD B,#0 + LD HL,#BBB_VALUE + ADD HL,BC + + LD A,(HL) + OR A ; niet mogelijk + RET Z + CP #2 ; al bezig + RET Z + CP #1 ; ga beginnen + JP Z,START_BUILD + + ; anders is ie ready !!!!!! + + LD A,E + LD C,A + ADD #64 ; 64 + item + + LD (ITEMSELECTED),A + LD A,#1 + LD (MBUSY),A + + LD HL,#BB_TYPES ; cursor + LD B,#0 + ADD HL,BC + LD A,(HL) + LD (BB_SIZE),A + + LD IX,(TNKADR) + RES 7,11(IX) ; geen tank + + LD IX,#IX_FOR_B + ; INC C + LD 1(IX),C + CALL P_BLD_IMG + CALL CANCEL_ITEM + + RET + +IX_FOR_B: + .db 0,0 + + +START_BUILD: + PUSH HL + + INC HL + INC HL + INC HL + LD A,(HL) + LD C,A + LD B,#0 + CALL CALC_MONEY + + POP HL + JR C,NO_START ; niet genoeg geld + + LD (HL),#2 + + LD A,D ; cursor positie + AND #0b11100000 + + LD IY,#BB_BLD2_COP + LD 4(IY),A + CALL PUTBLK + LD A,7(IY) + XOR #1 + LD 7(IY),A + CALL PUTBLK + RET + +NO_START: + LD A,#50 + LD (ISTEXT),A + LD A,#5 + CALL INIT_TEXT + RET + + +;----------------------------------------- +; OPTION MENU Win 98 version ! cool +; doet even nix +;----------------------------------------- + +OPTION_MENU: + LD A,#200 + LD (ISTEXT),A + LD A,#4 + CALL INIT_TEXT + RET + + LD A,(MBUSY) + OR A + RET NZ + + XOR A + LD (MSTOP),A + LD (MOUSE_SHAPE),A + LD (CURSOR_TYPE),A + CALL PULL_DOWN + +MENU_MAIN: + XOR A + ; CALL FIRE_BUTTON0 + CALL Z,MENU_COOR + + LD A,(MSTOP) + OR A + RET NZ + + JP MENU_MAIN + +MENU_COOR: + LD DE,(MOUSEY) + + LD A,D + CP #96 + JR C,MAREA2 + CP #144 + JR NC,MAREA2 + LD A,E + CP #125 + JR C,MAREA2 + CP #140 + JR NC,MAREA2 + + LD A,#1 + LD (MSTOP),A + RET +MAREA2: + RET + + +PULL_DOWN: + LD A,(SWAP) + LD IY,#MENU_COP + LD 7(IY),A + CALL SPRITES_OFF + LD B,#110 +DO_SCROLL: + XOR A + LD (JIFFY),A + + CALL MENU_SCRL + +MWAIT_LOOP: + LD A,(JIFFY) + CP #1 + ;JR C,MWAIT_LOOP + XOR A + LD (JIFFY),A + + DEC B + DEC B + + JR NZ,DO_SCROLL + CALL MENU_SCRL + CALL SPRITES_ON + RET + +MENU_SCRL: + LD A,#112 + SUB B + LD 2(IY),B + LD 10(IY),A + LD 8(IY),A + EXX + CALL PUTBLK + EXX + RET + +;--------------------------------------------- +; INTERRUPT ROUTINE !!! +;----------------------------------------- +INT_ROUTINE: + DI + PUSH AF + + ; XOR A + ; OUT (0x99),A + ; LD A,0x8F ; reg 15 op 0 + ; OUT (0x99),A + + IN A,(0x99) ; CHK OF INT VAN VDP IS + AND A + JP P,INT_NOT_V9938 + + PUSH BC + PUSH DE + PUSH HL + PUSH IX + PUSH IY + EXX + PUSH BC + PUSH DE + PUSH HL + CALL INTERRUPT + POP HL + POP DE + POP BC + EXX + POP IY + POP IX + POP HL + POP DE + POP BC +INT_NOT_V9938: + POP AF + EI + RETI ; Z80 NORM.... + +;--------------------------------------- + +INTERRUPT: + LD A,(ISTEXT) + OR A + JR Z,INTT_1 + DEC A + LD (ISTEXT),A + +INTT_1: + LD A,(BB_WAIT) + OR A + JR Z,INTT_2 + DEC A + LD (BB_WAIT),A +INTT_2: + CALL I_READ_BUTTONS ; buttons uitlezen + CALL READ_MOUSIE + + LD A,(ITEMSELECTED) + CP #128 + JP NC,INTT_3 + CP #64 + JP NC,PLACE_BB_SPR +INTT_3: + JP MULTIPLE_SEL + RET + +READ_MOUSIE: + ; Gebruik spratr om x en y op te slaan ! + + LD A,(MOUSE_PORT) ; Get mouse port in C + LD C,A +MOUSE1: + LD A,(MOUSE_WAIT1) + LD B,A ; Get Y move + CALL READ_MOUSE + RLCA + RLCA + RLCA + RLCA + LD H,A + CALL READ_MOUSE + OR H + LD H,A + CALL READ_MOUSE ; Get X move + RLCA + RLCA + RLCA + RLCA + LD L,A + CALL READ_MOUSE + OR L + LD C,H ; B = X-move / C = Y-move + LD B,A + + LD A,B ; Move -1,-1 ? + INC A + LD H,A + LD A,C + INC A + OR H + JR NZ,MOUSE3 + + LD A,(MOUSE_USE) ; Check mouse use + OR A + JR NZ,MOUSE2 + + LD A,(MOUSE_PORT) ; Check other port + XOR #0b01000000 + LD (MOUSE_PORT),A + + JR KEYBOARD + +MOUSE2: + LD A,(MOUSE_OFF) ; na 20 keer -1,-1 is uit + INC A + LD (MOUSE_OFF),A + CP #20 + JR C,MOUSE4 + XOR A ; Deactivate mouse + LD (MOUSE_USE),A + + JR KEYBOARD + +MOUSE3: ; Activate mouse / Keep mouse activat + XOR A ; counter op 0 + LD (MOUSE_OFF),A + DEC A ; wordt weer gebruikt + LD (MOUSE_USE),A + +MOUSE4: + LD A,B ; If mouse is moved then skip keyboar + OR C + JR NZ,CHK_PIJL_BORD ; niet 0,0 dan check + +KEYBOARD: + ; nog even geen keyboard + ; RET + + +CHK_PIJL_BORD: ; In: B=y-coordinaat + + LD HL,#SPRATR + LD A,(HL) + SUB B + + BIT 7,B + JR NZ,CHK_PIJL_BORD_Y1 + JR NC,CHK_PIJL_BORD_Y3 + XOR A + JR CHK_PIJL_BORD_Y3 + +CHK_PIJL_BORD_Y1: + JR NC,CHK_PIJL_BORD_Y2 + CP #204 + JR C,CHK_PIJL_BORD_Y3 + +CHK_PIJL_BORD_Y2: + LD A,#203 + +CHK_PIJL_BORD_Y3: + LD (HL),A + INC HL + + LD A,(HL) + SUB C + BIT 7,C + JR NZ,CHK_PIJL_BORD_X1 + JR NC,CHK_PIJL_BORD_X3 + XOR A + JR CHK_PIJL_BORD_X3 + +CHK_PIJL_BORD_X1: + JR NC,CHK_PIJL_BORD_X2 + CP #249 + JR C,CHK_PIJL_BORD_X3 +CHK_PIJL_BORD_X2: + LD A,#248 + +CHK_PIJL_BORD_X3: + LD (HL),A + +MOUSE_SPRITE: + DEC HL + ; spratr in hl !! + + LD A,#1 + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + + LD A,#0x00 ; ff + OUT (0x99),A + LD A,#0x76 ; 35 + OUT (0x99),A + + LD BC,#0x0498 + OTIR + RET + +READ_MOUSE: + LD A,#15 + OUT (0xA0),A + LD A,C + OUT (0xA1),A + XOR #0b00110000 + LD C,A + LD A,#14 + OUT (0xA0),A +READ_MOUSE_L: + DJNZ READ_MOUSE_L + + LD A,(MOUSE_WAIT2) + LD B,A + IN A,(0xA2) + AND #0x0F + RET + +;----------------------------------------- + +I_READ_BUTTONS: + XOR A + CALL I_FIR_P1 + LD (FIRE_BUTTONS),A + RET + +I_FIR_P1: LD B,A ; A=0 PORT 1 / A=1 PORT 2 + LD A,#15 + + OUT (0xA0),A + NOP + IN A,(0xA2) + + DJNZ I_FIR_S1 + AND #0xDF + OR #0x4C + JR I_FIR_S2 +I_FIR_S1: AND #0xAF + OR #3 +I_FIR_S2: OUT (0xA1),A + LD A,#14 + OUT (0xA0),A + NOP + IN A,(0xA2) + RET + +CHK_SPATIE: + IN A,(0xAA) ; check op spatie... + AND #0xF0 + OR #8 + OUT (0xAA),A + IN A,(0xA9) + AND #1 + RET + +;-------------------------------------------- +;- SUBS - +;-------------------------------------------- + +UPDATE_STEPS: + LD HL,#BBB_VALUE + LD B,#18 +UPD_STEPS_L1: + LD A,(HL) + CP #2 + JP Z,DO_STEP_UPD + INC HL + INC HL + INC HL + INC HL +UPD_STEPS_L2: + DJNZ UPD_STEPS_L1 + RET + +DO_STEP_UPD: + INC HL + LD A,(HL) + LD C,A + INC HL + LD A,(HL) + ADD C + CP #255 + JP Z,STEP_READY + LD (HL),A + INC HL + INC HL + JP UPD_STEPS_L2 +STEP_READY: + DEC HL + DEC HL + LD (HL),#3 + JP UPD_STEPS_L1 + +;--------------------------------------- + +MULTIPLE_SEL: + LD A,(PLAYFIELD) + OR A + JR Z,LABEL0009 + + LD A,(FIRE_BUTTONS) + BIT 4,A + JR Z,MS_1 +LABEL0009: ; ; ms uit + XOR A + LD (MS_COUNT),A + LD (HAS_SELECT),A + LD (TOTAL_SELECT),A + LD B,#4 + LD IX,#SPRATR+40 + LD DE,#4 +LABEL0008: + LD 0(IX),#212 + EXX + CALL PUT_SPRITE2 + EXX + ADD IX,DE + DJNZ LABEL0008 + + RET + +MS_1: + LD A,(MS_COUNT) + CP #10 + JR Z,MS_2_2 + INC A + LD (MS_COUNT),A + CP #9 + RET NZ +MS_2: + INC A + LD (MS_COUNT),A + LD HL,#SPRATR + LD E,(HL) + INC HL + LD D,(HL) + + LD (ORIGIN_Y),DE + LD A,#1 + LD (HAS_SELECT),A + EXX + LD A,(MSELECT_ON) + OR A + CALL NZ,MSEL_OFF + EXX + +MS_2_2: + LD HL,#SPRATR + LD E,(HL) + INC HL + LD D,(HL) + + LD A,(ORIGIN_X) + CP D + JR NC,LABEL0005 + LD (SEL_X0),A + LD A,D + LD (SEL_X1),A + JP LABEL0006 +LABEL0005: + LD (SEL_X1),A + LD A,D + LD (SEL_X0),A + +LABEL0006: + LD A,(ORIGIN_Y) + CP E + JR NC,LABEL0007 + LD (SEL_Y0),A + LD A,E + LD (SEL_Y2),A + JP SEL_METH1 +LABEL0007: + LD (SEL_Y2),A + LD A,E + LD (SEL_Y0),A + +SEL_METH1: + LD BC,(SEL_Y0) + LD HL,(SEL_Y2) + LD DE,#4 + + LD IX,#SPRATR+40 + LD 0(IX),C + LD 1(IX),B + EXX + CALL PUT_SPRITE2 + EXX + + ADD IX,DE + LD 0(IX),L + LD 1(IX),B + EXX + CALL PUT_SPRITE2 + EXX + + ADD IX,DE + LD 0(IX),C + LD 1(IX),H + EXX + CALL PUT_SPRITE2 + EXX + + ADD IX,DE + LD 0(IX),L + LD 1(IX),H + CALL PUT_SPRITE2 + + RET + +ORIGIN_Y: + .db 0 +ORIGIN_X: + .db 0 + +SEL_Y0: .db 0 +SEL_X0: .db 0 +SEL_Y2: .db 0 +SEL_X1: .db 0 + +;------------------------------------------ +A_TO_IY: + EXX ; schaduw BC,DE,HL !!!! + + OR A + CALL Z,CRASH + + LD IY,#TANK1-32 + + RRC A + RRC A + RRC A + LD B,A + + AND #0b11100000 + LD C,A + LD A,B + AND #0b00011111 + LD B,A + + ADD IY,BC + EXX + RET + +HL_TO_IX: INC HL + LD A,(HL) + DEC HL +A_TO_IX: + EXX ; schaduw BC,DE,HL !!!! + + OR A + CALL Z,CRASH + + LD IX,#TANK1-32 + + RRC A + RRC A + RRC A + LD B,A + + AND #0b11100000 + LD C,A + LD A,B + AND #0b00011111 + LD B,A + + ADD IX,BC + EXX + RET + +CRASH: + CALL COLOR_WHITE + + ; POP HL + ; POP HL + ; LD (CRASH_ADR),HL + + ;LD HL,#INT_DOS + ;CALL PUT_INT + + ;CALL SET_SCREEN0 + + ;LD SP,(EXIT_STACK) + RET ; einde prog + +EXIT_STACK: .dw 0 + +CRASH_ADR: + .dw 0 + +A_TO_BLD: + LD IY,#BUILDING1-BUILD_DATA + EXX + LD C,A + LD B,#0 + SLA C ; *2 + RL B + SLA C ; *4 + RL B + LD D,B ; DE met 4maal + LD E,C + ADD IY,DE + ADD IY,DE ; *8 + ADD IY,DE ; *12 + LD C,A + LD B,#0 + ADD IY,BC + EXX + RET + +;---------------------------------------------- + +VELD: + LD A,(SWAP) + LD (DOEL_PAGE),A + + XOR A + LD (DOEL_Y),A + LD (DOEL_X),A + + LD HL,(ADR) + DEC H + DEC HL + DEC HL + DEC HL + DEC HL + + LD DE,#CPYTT + + LD B,#12 ; 12 * 12 cpytt ; x in lengte + LD C,#12 +J8CAF: + LD A,(HL) + EX AF,AF + + LD A,C + CP #1 + JR Z,MAKE_CPYTT + CP #12 + JR Z,MAKE_CPYTT + + LD A,B + CP #1 + JR Z,MAKE_CPYTT + CP #12 + JR Z,MAKE_CPYTT + + LD A,(HL) + OR A + INC HL + JR Z,PUT_FIELD + LD A,#16 + LD (BRON_X),A + XOR A + JR CONT_VELD +PUT_FIELD: + LD A,(HL) + ADD A + ADD A + ADD A + ADD A + LD (BRON_X),A + LD A,(HL) + AND #0b11110000 +CONT_VELD: + LD (BRON_Y),A + LD A,(DOEL_X) + ADD #16 + LD (DOEL_X),A + + EXX + + LD HL,#FASTCOP + + DI ; vdp klaar ? + + LD A,#32 ; reg 32 + GEEN auto inc. + OUT (0x99),A ; als control register + LD A,#0x91 ;in reg 17 + OUT (0x99),A + + LD A,#2 ; waarde 2 in reg 15 + OUT (0x99),A + LD A,#0x8F ; execute + OUT (0x99),A +LUS3: + IN A,(0x99) ;lees status + RRA ; is CE nog 1 dan C is loop + JR C,LUS3 + + XOR A ; status reg. op 0 + OUT (0x99),A + LD A,#0x8F + OUT (0x99),A + + LD C,#0x9B + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + EI + + EXX + DEC HL +MAKE_CPYTT: + INC HL + INC HL + + EX AF,AF + OR A + JR NZ,CONT_CPYTT + LD A,(HL) + OR A + JR Z,CONT_CPYTT +BLW_CPYTT: + LD A,#1 + LD (DE),A + INC DE + LD A,(HL) ; nummer tank of zo ??? + LD (DE),A + INC DE +CONT_CPYTT: + INC HL + INC HL + DEC B + JP NZ,J8CAF + + DEC C + JR Z,END_VELD + + LD A,(DOEL_Y) + ADD #16 + LD (DOEL_Y),A + XOR A + LD (DOEL_X),A + + LD A,C + LD BC,#208 ; 54+128 ; !!! 64-10 + 2*64 + ADC HL,BC + LD C,A + LD B,#12 + JP J8CAF +END_VELD: + XOR A + LD (DE),A + INC DE + LD (DE),A ; laatste entry leeg + RET + + +;---------------------------------------- + +MLBC16: + LD B,#0 + LD C,A + + SLA C + RL B + SLA C + RL B + SLA C + RL B + SLA C + RL B + RET +;----------------------------------------- + +PTANK: + LD A,(OFFSET) + LD B,A + LD A,0(IX) + SUB B + INC A + ADD A,A + ADD A,A + ADD A,A + ADD A,A + ADD A,4(IX) + LD 4(IY),A + CP #16 + JP C,CONT2 + CP #161 + JP NC,CONT2 + LD A,(OFFSET+1) + LD B,A + LD A,1(IX) + SUB B + INC A + ADD A,A + ADD A,A + ADD A,A + ADD A,A + ADD A,5(IX) + LD 6(IY),A + CP #16 + JP C,CONT2 + CP #161 + JP NC,CONT2 + + CALL RITANK + CALL PUTBLK + LD 0(IY),#0 + LD 2(IY),#160 + + BIT 0,22(IX) + JP Z,IN_SCREEN + + LD HL,#0 ; super multiple select update + LD A,4(IY) + SRL A + LD C,A + LD B,#0 + ADD HL,BC + + LD A,6(IY) + LD D,A + LD B,A + SRL B + RR C + LD C,#0 + ADD HL,BC + LD A,D + AND #0b10000000 + RLC A + LD E,A + + CALL SETVDP + LD A,#0xFF + OUT (0x98),A + + LD BC,#7 + ADD HL,BC + + LD A,E + CALL SETVDP + LD A,#0xFF + OUT (0x98),A +;---------------------------------- + LD BC,#15*128-7 + ADD HL,BC + + LD A,D + ADD #15 + AND #0b10000000 + RLC A + LD E,A + + CALL SETVDP + LD A,#0xFF + OUT (0x98),A + + LD BC,#7 + ADD HL,BC + + LD A,E + CALL SETVDP + LD A,#0xFF + OUT (0x98),A + + JP IN_SCREEN + +PTANK_UP: + LD 4(IY),C + + LD 6(IY),B + + LD A,#176 + SUB B + LD 10(IY),A + + + LD 8(IY),#16 + CALL RITANK + CALL PUTBLK + LD 2(IY),#160 + LD 10(IY),#16 + LD 0(IY),#0 + RET + +PTANK_LT: + LD 6(IY),B + LD 4(IY),C + + LD A,#176 + SUB C + LD 8(IY),A + + ; LD 4(IY),A + LD 10(IY),#16 + CALL RITANK + CALL PUTBLK + LD 0(IY),#0 + LD 2(IY),#160 + RET + +PTANK_DN: + LD 4(IY),C + LD 10(IY),B + LD A,#16 + SUB B + ADD #160 + LD 2(IY),A + LD 6(IY),#16 + LD 8(IY),#16 + CALL RITANK + CALL PUTBLK + LD 0(IY),#0 + LD 2(IY),#160 + RET + +PTANK_RI: + LD 6(IY),B + LD 8(IY),C ; offset copieren + LD A,#16 + SUB C + LD 0(IY),A + LD 4(IY),#16 + LD 10(IY),#16 + CALL RITANK + CALL PUTBLK + LD 0(IY),#0 + LD 2(IY),#160 + RET + +RITANK: LD A,9(IX) ; richting + AND #0b00000111 ; eventuele radar found bitje weg.. + ADD A,A + ADD A,A + ADD A,A + ADD A,A + ADD A,0(IY) + LD 0(IY),A + LD A,11(IX) + AND #0b00000111 ; type tank + ADD A,A + ADD A,A + ADD A,A + ADD A,A + ADD A,2(IY) + LD 2(IY),A + LD A,13(IX) + AND #0b10000000 ;soort bit + ADD A,0(IY) + LD 0(IY),A + RET +;--------------------------------------------- + +XYTO16: LD A,D + SRL A + SRL A + SRL A + SRL A + LD B,A + LD A,(OFFSET) + ADD A,B + DEC A + LD D,A + LD A,E + SRL A + SRL A + SRL A + SRL A + LD B,A + LD A,(OFFSET+1) + ADD A,B + DEC A + LD E,A + RET + +;------------------------------------ +;--- sub routine blocked !!! +;----------------------------------- + +BLCKED: + LD A,(HL) + CP #64 + RET ; deze return waarde kan nog veranderen ! + +CALC_ADR: + LD HL,#VELD_ADRES + + LD A,C ; Y MAAL 256 + ADD H + LD H,A + + SLA B ; X MAAL 4 + SLA B + LD C,B + LD B,#0 + ADD HL,BC ; plus x + INC HL + RET + + ; + ; PUSH HL + ; PUSH IX + + ; INC HL + ; LD A,(HL) + ; OR A + ; JR Z,CALC_ADR2 + + ; CALL A_TO_IX + ; LD B,0(IX) + ; LD C,1(IX) + + ; LD HL,VELD_ADRES + + ; LD A,C ; Y MAAL 256 + ; ADD H + ; LD H,A + + ; SLA B ; X MAAL 4 + ; SLA B + ; LD C,B + ; LD B,0 + ; ADD HL,BC ; plus x + ; INC HL + + ; POP IX + ; POP BC + + ; SBC HL,BC + ;JP NZ,CRASH + + ; PUSH BC + ; POP HL + ; RET + ; + +CALC_ADR2: + ; POP IX + ; POP HL + + ; RET + +;-------------------------------------- +; UPD_TANK_LAY +;-------------------------------------- +RES_TANK_LAY: + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + + LD A,(HL) + CP #1 + JR Z,RES_TANK_LAY2 + CP #16 + JR NC,RES_TANK_LAY2 + + LD A,9(IX) + AND #0b00000011 + ADD #2 + LD (HL),A + +RES_TANK_LAY2: + LD B,#0 + LD A,13(IX) + CP #127 + JR NC,NO_RADREVEAL ; rood ontdekt niet !! + LD B,#255 +NO_RADREVEAL: + INC B + + INC HL + LD (HL),#0 ; RESET tank positie + RET + +;----------------------------------------------- +CLEAR_ITEM: + XOR A + LD (ITEMSELECTED),A + LD (CURSOR_TYPE),A + LD (MBUSY),A + LD (ACTIVE_MENU),A ; commando balk reset + + CALL SPRITES_OFF + + LD IY,#MENU_COM_CLN + XOR A + LD 7(IY),A + LD A,#72 + LD 6(IY),A + CALL PUTBLK + LD A,#80 + LD 6(IY),A + CALL PUTBLK + LD A,#88 + LD 6(IY),A + CALL PUTBLK + LD A,#96 + LD 6(IY),A + CALL PUTBLK + LD A,#58 + LD 6(IY),A + CALL PUTBLK + + LD IY,#MENU_COM_SWP + CALL PUTBLK + + LD IY,#EMPTY + LD 7(IY),#0 + CALL PUTBLK + LD 7(IY),#1 + CALL PUTBLK + + JP SPRITES_ON + +SHOW_POWER: + LD A,(ITEMSELECTED) + OR A + RET Z + + CP #2 + JP Z,HARV_INHOUD + + CP #127 + JR NC,BUILDING_POW + CP #64 + RET NC + + LD IX,(TNKADR) + LD A,12(IX) ; power berekenen + JP SHOW_POW2 + +BUILDING_POW: + LD IX,(P_BUILD) + LD A,6(IX) + +SHOW_POW2: + EX AF,AF + + LD A,(SWAP) + XOR #1 + LD E,A + + LD IY,#POWER_INFO ; volledige balk + LD 7(IY),E ; naar onzichtbare scherm + CALL PUTBLK + EX AF,AF + + SRL A + SRL A + SRL A + LD B,A + LD A,#31 + SUB B + RES 0,A ; even getal + OR A + JR Z,SHOW_POW3 ; full power + ; + + LD IY,#POWER_BALK + LD 8(IY),A + LD 7(IY),E + CALL PUTBLK +SHOW_POW3: + LD IY,#POWER_COP + LD 3(IY),E ; from onzichtbaar + LD A,E + XOR #1 + LD 7(IY),A ; to zichtbaar + CALL PUTBLK + ; nou nog het upgrade balkje + + LD A,(ITEMSELECTED) + CP #127 + RET C + + BIT 1,8(IX) + RET Z ; geen upgrade bar + + LD A,11(IX) ; upgrade status + OR A + RET Z + + SRL A + SRL A + SRL A + RES 0,A + OR A + RET Z + LD B,A + + LD IY,#HARV_BALK + + LD A,#32 + SUB B + LD 2(IY),A + + ADD #24 + LD 6(IY),A + LD 10(IY),B + LD A,(SWAP) + LD 7(IY),A + EX AF,AF + CALL PUTBLK + LD IY,#HARV_COP + EX AF,AF + LD 3(IY),A + XOR #1 + LD 7(IY),A + JP PUTBLK + RET + + + +HARV_INHOUD: ; ; harv inhoud displayen + LD IX,(TNKADR) + LD A,16(IX) + CP #7 + RET C + SUB #6 + SRL A + LD B,A + + LD IY,#HARV_BALK + + LD A,#32 + SUB B + LD 2(IY),A + + ADD #24 + LD 6(IY),A + LD 10(IY),B + LD A,(SWAP) + LD 7(IY),A + EX AF,AF + CALL PUTBLK + LD IY,#HARV_COP + EX AF,AF + LD 3(IY),A + XOR #1 + LD 7(IY),A + JP PUTBLK + +COMMAND_TANK: + LD D,#0b10000111 + JP EXTRACT_COM +COMMAND_HARV: + LD D,#0b00011110 + JP EXTRACT_COM +COMMAND_B: + LD IY,(P_BUILD) + LD D,#0b01000000 + BIT 0,8(IY) + JR NZ,COMMAND_B3 + + LD D,#0b00100000 + BIT 1,8(IY) + JR NZ,COMMAND_B3 + + LD D,#0 + LD A,6(IY) + CP #255 ; niet helemaal + JR Z,COMMAND_B2 ; ?huh + + LD D,#0b01000000 +COMMAND_B2: + LD A,10(IY) + SUB 9(IY) + JR Z,COMMAND_B4 + LD A,#0b00100000 + OR D + LD D,A + JP COMMAND_B4 +COMMAND_B3: + LD A,#0b10000000 + OR D + LD D,A + +COMMAND_B4: + JP EXTRACT_COM + +CANCEL_ITEM: + LD D,#0b10000000 + JP EXTRACT_COM +COMMAND_ENM: + LD D,#0 +EXTRACT_COM: + CALL SPRITES_OFF + + LD IY,#MENU_COM_CLN + XOR A + LD 7(IY),A + LD A,#72 + LD 6(IY),A + CALL PUTBLK + LD A,#80 + LD 6(IY),A + CALL PUTBLK + LD A,#88 + LD 6(IY),A + CALL PUTBLK + LD A,#96 + LD 6(IY),A + CALL PUTBLK + + BIT 0,D + LD IY,#MENU_COM_ATT + CALL NZ,PUTBLK + BIT 1,D + LD IY,#MENU_COM_MOV + CALL NZ,PUTBLK + BIT 2,D + LD IY,#MENU_COM_STP + CALL NZ,PUTBLK + BIT 3,D + LD IY,#MENU_COM_RET + CALL NZ,PUTBLK + BIT 4,D + LD IY,#MENU_COM_HRV + CALL NZ,PUTBLK + BIT 5,D + LD IY,#MENU_COM_UPG + CALL NZ,PUTBLK + BIT 6,D + LD IY,#MENU_COM_REP + CALL NZ,PUTBLK + BIT 7,D + LD IY,#MENU_COM_CAN + CALL NZ,PUTBLK + + LD IY,#MENU_COM_SW2 + CALL PUTBLK + JP SPRITES_ON + +;------------------------------------------- + +REMOVE_TANK: + ; XOR A ; sample nummer 0 + ; CALL PLAY + + LD D,0(IX) + LD E,1(IX) + LD B,D + LD C,E + + PUSH IX + LD IX,#PLOF_BUF + LD 0(IX),D + LD 1(IX),E + CALL ADD_PLOFJE + POP IX + + CALL CALC_ADR ; 2 byte veld layer op 0 + LD A,(HL) + CP #16 + JR NC,REMOVE_TANK2 + LD A,R + AND #0b00000011 + ADD #6 + LD (HL),A +REMOVE_TANK2: + INC HL + LD (HL),#0 + + LD C,25(IX) ; Y + LD B,24(IX) ; X + CALL CALC_ADR + DEC HL + LD A,(HL) + OR A + JR NZ,REMOVE_TANK3 + INC HL + CALL POINT + LD D,A + + CALL PLACE_UNIT +REMOVE_TANK3: + BIT 7,11(IX) + CALL NZ,CLEAR_ITEM + + LD A,23(IX) + AND #0x0F + CALL NZ,AI_UPDATE ; ALS TNK EEN MIS HEEFT UPD DAN + + LD A,13(IX) ; nummer tank + LD H,A + + LD B,#254 ; tank sum + LD DE,#TANK_DATA ;loop door de tabel om attack + LD IY,#TANK1 ; nummers te resetten !! +LABEL0010: + LD A,14(IY) + CP H + CALL Z,RES_ATTACK + + ADD IY,DE + DJNZ LABEL0010 + + ; remove tank uit tnk_totaal + ; verschilt per tank + + LD A,13(IX) + CP #128 + JR C,REM_TNK_BLW + + LD HL,(DED_CNT_RED) + INC HL + LD (DED_CNT_RED),HL + + LD HL,#TNK_CNT_RED + JR LABEL0012 +REM_TNK_BLW: + LD HL,(DED_CNT_BLW) + INC HL + LD (DED_CNT_BLW),HL + + LD HL,#TNK_CNT_BLW +LABEL0012: + DEC (HL) + + PUSH IX + POP HL + LD BC,#TANK_DATA +LABEL0011: + LD (HL),#0 + INC HL + DEC BC + LD A,B + OR C + JP NZ,LABEL0011 + + RET + +RES_ATTACK: + LD 14(IY),#0 + RES 5,11(IY) + RES 6,11(IY) + SET 4,11(IY) + LD A,22(IY) ; reset inslag shoot en + AND #0b10000001 ; of er op je geschotenis + LD 22(IY),A + + LD A,0(IY) + LD 2(IY),A + LD A,1(IY) + LD 3(IY),A + RET + +REMOVE_BUILD: + LD IX,#PLOF_BUF + + LD D,2(IY) + LD E,3(IY) + LD B,D + LD C,E + CALL CALC_ADR + LD B,5(IY) ;hoogte gebouw +REM_B_LOOPY: + PUSH HL + PUSH DE + PUSH BC + + LD B,4(IY) ; lengte gebouw +REM_B_LOOPX: + LD 0(IX),D + LD 1(IX),E + + CALL ADD_PLOFJE + LD A,R + AND #0b00000011 + ADD #65 + LD (HL),A ; random stukje + INC D + INC HL + INC HL + INC HL + INC HL + DJNZ REM_B_LOOPX + + POP BC + POP DE + POP HL + + INC E + INC H + + DJNZ REM_B_LOOPY + + LD HL,#BUILDINGS + DEC (HL) ; gebouw -1 + + LD A,0(IY) + LD 0(IY),#0 ; nummer op 0 is gebouw weg + + LD A,(ITEMSELECTED) + BIT 7,A + RET Z + + PUSH IY + POP BC + LD IX,(P_BUILD) + PUSH IX + POP HL + SBC HL,BC + JP Z,CLEAR_ITEM + RET +;----------------------------------- +; ADD_PLOFJE +; +; IN: PLOF_BUF GEVULD ! X EN Y +; +;----------------------------------- + +PLOF_BUF: .db 0,0 + +ADD_PLOFJE: + EXX + LD A,(PLOF_BUF) + LD D,A + LD A,(PLOF_BUF+1) + LD E,A + + LD HL,#PLOF_TABEL + INC HL + INC HL + LD A,#80 ; max ontplof stukjes + LD B,A +CHECK_PLOF: + LD A,(HL) + OR A + JR Z,LABEL0002 + + INC HL + INC HL + INC HL + DJNZ CHECK_PLOF ; even opletten + RET ; max. plof bereikt +LABEL0002: + + LD A,(PLOF_COUNT) + INC A ; 1 plofke erbij + LD (PLOF_COUNT),A + + LD (HL),#8 ; NUMMER + DEC HL + LD (HL),E ; EN Y + DEC HL + LD (HL),D ; EN X + EXX + RET + +;---------------------------------- +; SPICE PLOF +;---------------------------------- + +WAIT: .db 0 + +SPICE_BOOM: + LD A,(WAIT) + INC A + AND #0b00000111 + LD (WAIT),A + RET NZ + + LD IX,(TNKADR) + LD B,0(IX) + LD C,1(IX) + CALL CALC_ADR + PUSH HL + LD IX,#SPICE_RAD + LD B,#9 +SPICE_BOOM_LP: + POP HL + PUSH HL + LD E,0(IX) + LD D,1(IX) + ADC HL,DE + LD D,#0 + LD A,(HL) + CP #48 + JR NC,END_BOOM_LP + + CP #16 + JR C,NORMAL_SPICE + + CP #32 + JR C,EXTRA_SPICE + + LD (HL),#32 + JR END_BOOM_LP +EXTRA_SPICE: + LD A,#16 + LD D,A +NORMAL_SPICE: + LD A,2(IX) + ADD D + LD (HL),A +END_BOOM_LP: + LD DE,#3 + ADD IX,DE + DJNZ SPICE_BOOM_LP + POP HL + RET + +;----------------------------------- +; Music Module init +;----------------------------------- + +MMODULE_INIT: + LD B,#12 + LD HL,#PDATA_1 + +PLOOP1: LD A,(HL) + OUT (0xC0),A ; OUT REG + INC HL + LD A,(HL) + OUT (0xC1),A ; OUT INHOUD + INC HL + DJNZ PLOOP1 ; TILL B=0 + RET + + +;------------------------------------ +; Play a sample +; A register bevat nummer sample +;----------------------------------- + +PLAY: + LD HL,#SAMPLES + SLA A + LD C,A + LD B,#0 + ADD HL,BC + LD E,(HL) + INC HL + LD D,(HL) + EX DE,HL + + LD B,#6 + +PLOOP2: LD A,(HL) + OUT (0xC0),A ; OUT REG + INC HL + LD A,(HL) + OUT (0xC1),A ; OUT INHOUD + INC HL + DJNZ PLOOP2 ; TILL B=0 + RET + +SAMPLES: + .dw SAM_PLOF1 + .dw SAM_PLOF2 + +SAM_PLOF1: + .db 7,1 ; MOET!!! + .db 9,0 + .db 10,0 + .db 11,0xFF ; EI LOW + .db 12,0x07 ; EI HI + .db 7,0xA0 ; IETS (0xA0 IS PLAY) + +SAM_PLOF2: + .db 7,1 ; MOET!!! + .db 9,0 + .db 10,0 + .db 11,0xFF ; EI LOW + .db 12,0x07 ; EI HI + .db 7,0xA0 ; IETS (0xA0 IS PLAY) + + +; --------- swap mode ---------------- + +CHANGE_INT: + DI ; is dit nodig ? + LD A,(0xF3DF) + RES 4,A + LD (0xF3DF),A + OUT (0x99),A + LD A,#128+0 + OUT (0x99),A + + LD A,#16 + OUT (0x99),A + LD A,#128+19 + OUT (0x99),A + EI + RET + +;--------------------------------- +; CALCULATE MONEY +; BC bevat bedrag * 10 +; UIT Carry is te weinig !!! +;--------------------------------- + +CALC_MONEY: + LD HL,(MONEY) + SBC HL,BC + RET C + LD (MONEY),HL + RET + +;--------------------------------- +; PLAATS MONEY +;---------------------------------- + +PUT_MONEY: + LD HL,(DIS_MONEY) + LD BC,(MONEY) + SBC HL,BC + RET Z + LD HL,(DIS_MONEY) + JR C,INC_MONEY + + DEC HL + DEC HL + DEC HL + DEC HL +INC_MONEY: + INC HL + INC HL + + LD (DIS_MONEY),HL + + LD IY,#DEEL2 + LD IX,#MONEY_CHAR + LD B,#5 ; aantal cijfers te delen + + CALL DLINI + + LD IX,#MONEY_CHAR + LD HL,(MONEY_POS) + LD D,#5 + + JP PUT_CHARS + +PUT_FPS: + RET + + ; LD HL,(DED_CNT_RED) + ; LD IY,DEEL2 + ; LD IX,MONEY_CHAR + ; LD B,5 ; aantal cijfers te delen + + ; CALL DLINI + ; + ; LD IX,MONEY_CHAR + ; LD HL,(MONEY_POS) + ; LD D,5 + + ; JP PUT_CHARS + +;---------------------------------- +; DEEL - delen van getallen +;---------------------------------- + +DLINI: + LD D,1(IY) + LD E,0(IY) + XOR A + +DEEL: + SBC HL,DE + JR C,ENDLP1 + INC A + JR DEEL +ENDLP1: + ADD HL,DE + LD 0(IX),A + LD A,B + CP #1 + RET Z + + INC IX + INC IY + INC IY + DEC B + LD D,1(IY) + LD E,0(IY) + XOR A + JR DEEL +;---------------------------------------- +; PUT KARAKTER +;------------------------------------- + +PUT_CHARS: + LD IY,#LETCOP + LD 4(IY),L + LD 6(IY),H +PUT1LP: + LD A,0(IX) + SLA A + SLA A + SLA A ;3 KEER = 8 > 2^3 + ;LD B,A + ; LD A,96 + ;ADD B + LD 0(IY),A + + CALL PUTBLK + LD A,7(IY) + XOR #1 + LD 7(IY),A + CALL PUTBLK + + LD A,4(IY) + ADD #8 + LD 4(IY),A + + INC IX + DEC D + JR NZ,PUT1LP + RET +;-------------------------------------------- + +INIT_TEXT: + EXX + LD HL,#TEXTTAB + LD B,#0 + LD C,A + SLA C + RL B + ADD HL,BC + LD E,(HL) + INC HL + LD D,(HL) + LD (TEXTADR),DE + EXX + RET + +;-------------------------------------------- +PUT_TEXT: + LD IY,#LETCOP2 + LD DE,(TEXTADR) + + LD 4(IY),#20 + LD 6(IY),#20 +PUT2LP: + LD A,(DE) + CP #255 + RET Z + CP #32 + JR Z,PUT2LP_CONT +DEBUG: + SUB #46 + LD B,#0 + SLA A + RL B + SLA A + RL B + SLA A ;3 KEER = 8 > 2^3 + RL B + LD 0(IY),A + SLA B + SLA B + SLA B + LD A,B + ADD #136 + LD 2(IY),A + + LD A,(SWAP) + LD 7(IY),A + CALL PUTBLK +PUT2LP_CONT: + INC DE + LD A,4(IY) + ADD #6 + LD 4(IY),A + CP #160 + JR C,PUT2LP + LD A,6(IY) + ADD #8 + LD 6(IY),A + LD A,#20 + LD 4(IY),A + JR PUT2LP + +;-------------------------------------- + +; routine voor kopieren van stukken scherm +; gewijzigd worden + +; AF +; BC +; HL + +PUTBLK: + + DI ; vdp klaar ? + LD A,#2 ; waarde 2 in reg 15 + OUT (0x99),A + LD A,#0x8F ; execute + OUT (0x99),A + NOP + NOP ; wacht op vdp +LUS2: + IN A,(0x99) ;lees status + RRA ; is CE nog 1 dan C is loop + JR C,LUS2 + + XOR A ; status reg. op 0 + OUT (0x99),A + LD A,#0x8F ; reg 15 op 0 voor int! + OUT (0x99),A + + PUSH IY ; hl moet iy bevatten !! + POP HL + + LD A,#0x20 ; register 32 + OUT (0x99),A ; als control register + LD A,#0x91 ;in reg 17 + OUT (0x99),A + ; LD BC,0x0F9B ; 15 bytes naar port 9b + + LD C,#0x9B + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + OUTI + EI + + RET + + + +;-------------------------------------------- +; put sprite +; in = IX met attribuut tabel bevat ook nummer sprite +;----------------------------------------- + + +PUT_SPRITE: + DI + LD A,#1 + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + LD C,3(IX) + LD B,#0 + LD HL,#0x7600 ; ipv 35FF + ADD HL,BC + LD A,L + OUT (0x99),A + LD A,H + OUT (0x99),A + PUSH IX + POP HL ; hl bevat attribuut tabel + LD BC,#0x0498 + OTIR + EI + RET + +PUT_SPRITE2: + LD A,#1 + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + LD C,3(IX) + LD B,#0 + LD HL,#0x7600 ; ipv 35FF + ADD HL,BC + LD A,L + OUT (0x99),A + LD A,H + OUT (0x99),A + PUSH IX + POP HL ; hl bevat attribuut tabel + LD BC,#0x0498 + OTIR + RET + +SPRITE_CLR: + LD A,#1 ; Zet sprite kleur + OUT (0x99),A + LD A,#0x8E + OUT (0x99),A + + LD HL,#0x7400 ; 33FF + ADD HL,BC + + LD A,L + OUT (0x99),A + LD A,H + OUT (0x99),A + + EX DE,HL + LD BC,#0x1098 + OTIR + RET + +PLACE_BB_SPR: + XOR A + LD (BB_BLOCKED),A + LD A,#1 + LD (BB_OUT_RANGE),A + + LD IX,#SPRATR+16 + LD IY,#BB_SERIE + + LD HL,#SPRATR + + LD A,(HL) + AND #0b11110000 + LD E,A + + INC HL + LD A,(HL) + AND #0b11110000 + LD D,A + PUSH DE + + CALL XYTO16 ; adres van eerste + LD B,D + LD C,E + CALL CALC_ADR + + LD A,(BB_SIZE) + LD 0(IY),A ; size in serie + INC IY + LD B,A + +SPR_LOOP0: + LD A,(BB_OUT_RANGE) + OR A + JR Z,SPR_LOOP0_CNT + + CALL IS_OUT_RANGE + ; LD A,(BB_OUT_RANGE) + ; OR A + ; JR NZ,ADD_RED +SPR_LOOP0_CNT: + DEC HL + LD A,(HL) + INC HL + LD D,(HL) + INC HL + LD E,(HL) + DEC HL + OR A + JR NZ,ADD_RED + LD A,E + OR A + JR NZ,ADD_RED + LD A,D + CP #64 + JR C,ADD_RED + CP #80 + JR NC,ADD_RED + +ADD_WHT: + XOR A + LD 0(IY),A + JP END_LOOP0 +ADD_RED: + LD A,#1 + LD 0(IY),A + +END_LOOP0: + INC IY + CALL CALC_NXT_ADR + + DJNZ SPR_LOOP0 + + POP DE ;adres weer terug + + LD IY,#BB_SERIE + + LD B,0(IY) + LD C,#0 + INC IY +SPR_LOOP1: + PUSH BC + + PUSH DE + + LD A,E + CP #16 + JP C,OUT_RANGE + CP #176 + JP NC,OUT_RANGE + LD A,D + CP #16 + JP C,OUT_RANGE + CP #176 + + JP C,IN_RANGE + +OUT_RANGE: + LD E,#212 +IN_RANGE: + LD 0(IX),E + LD 1(IX),D + + CALL KAN_BB_SPR + POP DE + + LD BC,#4 + ADD IX,BC + INC IY + + POP BC + INC C + CALL NEXT_COOR + + DJNZ SPR_LOOP1 + RET + +NEXT_COOR: + LD A,B + DEC A + RET Z + + CP #1 + JP Z,NEXT_COOR1 + + CP #2 + JP Z,NEXT_COOR2 + + CP #3 + JP Z,NEXT_COOR1 + + CP #4 + JP Z,NEXT_COOR2 + +NEXT_COOR1: + LD A,E + ADD A,#16 + LD E,A + RET + +NEXT_COOR2: + LD A,D + ADD A,#16 + LD D,A + LD A,E + SUB #16 + LD E,A + RET + +CALC_NXT_ADR: + LD A,B + DEC A + RET Z + + CP #1 + JP Z,NEXT_ADR1 + + CP #2 + JP Z,NEXT_ADR2 + + CP #3 + JP Z,NEXT_ADR1 + + CP #4 + JP Z,NEXT_ADR2 +NEXT_ADR1: + INC H + RET +NEXT_ADR2: + DEC H + INC HL + INC HL + INC HL + INC HL + RET + +KAN_BB_SPR: + LD A,C + ADD #4 + LD C,A + SLA C + SLA C + SLA C + SLA C + LD B,#0 + + LD A,0(IY) + CP #0 + JP Z,BB_SPR_WHT + JP BB_SPR_RED + +IS_OUT_RANGE: + PUSH HL + LD D,#1 + + DEC H + CALL BB_TEST_RANGE + + INC HL + INC HL + INC HL + INC HL + CALL BB_TEST_RANGE + + INC H + CALL BB_TEST_RANGE + INC H + CALL BB_TEST_RANGE + + DEC HL + DEC HL + DEC HL + DEC HL + CALL BB_TEST_RANGE + + DEC HL + DEC HL + DEC HL + DEC HL + CALL BB_TEST_RANGE + + DEC H + CALL BB_TEST_RANGE + DEC H + CALL BB_TEST_RANGE + POP HL + + LD A,D + LD (BB_OUT_RANGE),A + + RET +BB_TEST_RANGE: + LD A,(HL) + CP #128 + RET NC + + LD (STORAGE1),A + + LD A,(ITEMSELECTED) + CP #64 + JR NZ,BB_TEST_RANGE2 + + LD A,(HL) + CP #64 + JR Z,BB_TEST_RANGE3 +BB_TEST_RANGE2: + LD A,(STORAGE1) + CP #96 + RET C +BB_TEST_RANGE3: + LD D,#0 + RET + +STORAGE1: .db 0 + + +BB_SPR_WHT: + LD A,(BB_OUT_RANGE) + OR A + JR NZ,BB_SPR_RED + + LD DE,#SPRKLR_WHT + CALL SPRITE_CLR + JP PUT_SPRITE2 +BB_SPR_RED: + LD A,#1 + LD (BB_BLOCKED),A + LD DE,#SPRKLR_RD + CALL SPRITE_CLR + JP PUT_SPRITE2 +;-------------------------------------------------- +; ADD TANK !! +; +; routine die een tank toevoegd +; +; IN: +; HL = coordinaten H=Y L=X +; BC = soort tank & type B=soort C=type +; +; UIT: +; A = nummer tank > 0 is gelukt +; +;----------------------------------------------- +ADD_TANK: + LD A,B + OR A + JP Z,ADD_TNK_RED + + LD A,(TNK_CNT_BLW) + CP #127 ; NIET MEER DAN 127 TANKS + LD A,#0 + RET Z ; + + LD A,(TNK_CNT_BLW) + INC A + LD (TNK_CNT_BLW),A + + LD IX,#TEMPLATE_TNK + LD 11(IX),C + + LD 0(IX),H ; X EN Y + LD 2(IX),H + LD 1(IX),L ; + LD 3(IX),L ; dest. = source + + LD IY,#TANK1 + LD DE,#TANK_DATA + LD B,#0 ; niet 0 MAAR 1 !!!!! +LP_CALC_BLW: + INC B + LD A,13(IY) + OR A + JR Z,ADD_TANK3 + ADD IY,DE + JR LP_CALC_BLW + +ADD_TANK3: + LD 13(IX),B ; nummer + LD 12(IX),#255 ; power + + LD HL,#TEMP_HARV ; search template + LD B,#0 + SLA C + SLA C + ADD HL,BC + + LD A,(HL) + LD 10(IX),A ;speed byte + INC HL + LD A,(HL) + LD 16(IX),A ; attack + INC HL + LD A,(HL) + LD 17(IX),A ; shield + INC HL + LD A,(HL) + LD 18(IX),#1 ; wait time + LD 19(IX),A + + PUSH IX + POP HL ;bron + LD BC,#TANK_DATA ; aantal + PUSH IY + POP DE ; dest + LDIR + + LD B,0(IY) + LD C,1(IY) + CALL CALC_ADR + LD A,13(IX) + INC HL + LD (HL),A ; update veld layer + DEC HL + DEC HL + LD (HL),#0 + RET + + +ADD_TNK_RED: + LD A,(TNK_CNT_RED) + CP #127 ; NIET MEER DAN 127 TANKS + LD A,#0 + RET Z ; + + LD A,(TNK_CNT_RED) + INC A + LD (TNK_CNT_RED),A + + LD IX,#TEMPLATE_TNK + LD 11(IX),C + + LD 0(IX),H ; X EN Y + LD 2(IX),H + LD 1(IX),L ; + LD 3(IX),L ; dest. = source + + LD IY,#TANKRED + LD DE,#TANK_DATA + LD B,#127 ; dan is ie 128 bij de eerste loop +LP_CALC_RED: + INC B + LD A,13(IY) + OR A + JR Z,ADD_TANK4 + ADD IY,DE + JR LP_CALC_RED + +ADD_TANK4: + LD 13(IX),B ; nummer + LD 12(IX),#255 ; power + + LD HL,#TEMP_HARV ; search template + LD B,#0 + SLA C + SLA C + ADD HL,BC + + LD A,(HL) + LD 10(IX),A ;speed byte + INC HL + LD A,(HL) + LD 16(IX),A ; attack + INC HL + LD A,(HL) + LD 17(IX),A ; shield + INC HL + LD A,(HL) + LD 18(IX),#1 ; wait time + LD 19(IX),A + + PUSH IX + POP HL ;bron + LD BC,#TANK_DATA ; aantal + PUSH IY + POP DE ; dest + LDIR + + LD B,0(IY) + LD C,1(IY) + CALL CALC_ADR + LD A,13(IX) + INC HL + LD (HL),A ; update veld layer + RET + + +TEST_ADD_TNK: + ; LD HL,(MONEY) ; MAX 2TOTDE15 + ; LD BC,30 + ; XOR A + ; SBC HL,BC + ; RET C + + LD A,R + AND #0b00000011 + ADD #25 + LD B,A + + LD C,#18 + PUSH BC + CALL CALC_ADR + INC HL + LD A,(HL) + OR A + POP HL + RET NZ + + LD A,R + AND #0b00000001 + LD B,#1 ; 1 = blauw / 0 = rood + LD A,#3 ; random tank !! + ; AND 0b00000011 ; joepie werkt !! + INC A ; 0 = 1 / 3 = 4 + LD C,A + CALL ADD_TANK + OR A + RET Z + + LD HL,(MONEY) ; MAX 2TOTDE15 + LD BC,#30 + XOR A + SBC HL,BC + LD (MONEY),HL + + RET + +MAKE_RED_BASE: + LD B,#25 ; over de steentjes heen.... + LD C,#13 ; dit moet ook weg !! + CALL CALC_ADR + LD (HL),#96 + INC HL + INC HL + INC HL + INC HL + LD (HL),#97 + INC H + LD (HL),#99 + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),#98 + + LD B,#50 ; dit kan dus hierna weer weg ! + LD C,#46 + CALL CALC_ADR + LD (HL),#112+16 + INC HL + INC HL + INC HL + INC HL + LD (HL),#113+16 + INC H + LD (HL),#115+16 + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),#114+16 + + LD B,#49 ; dit kan dus hierna weer weg ! + LD C,#49 + CALL CALC_ADR + LD (HL),#118+32 ; factory + INC HL + INC HL + INC HL + INC HL + LD (HL),#119+32 + INC HL + INC HL + INC HL + INC HL + LD (HL),#120+32 + INC H + LD (HL),#123+32 + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),#122+32 + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),#121+32 + + LD B,#53 ; EN DIT OOK + LD C,#46 + CALL CALC_ADR + LD (HL),#132 + INC HL + INC HL + INC HL + INC HL + LD (HL),#133 + INC H + LD (HL),#135 + DEC HL + DEC HL + DEC HL + DEC HL + LD (HL),#134 + RET + +FREE_BLW_BASE: ; ; maak wat radar schoon ! + LD B,#25 + LD C,#10 + CALL FREE_PART + LD B,#29 + LD C,#12 + CALL FREE_PART + LD B,#28 + LD C,#19 + CALL FREE_PART + LD B,#50 ; stukie rode base + LD C,#46 + CALL FREE_PART + LD B,#49 + LD C,#52 + CALL FREE_PART + LD B,#53 + LD C,#49 + CALL FREE_PART + RET +FREE_PART: + LD DE,#RAD_SIEGE + CALL FREE_PART_LOOP + CALL CALC_ADR + DEC HL + LD (HL),#0 + RET + +FREE_PART_LOOP: + LD A,(DE) + CP #100 + RET Z + + PUSH BC + + ADD B + LD B,A + INC DE + + LD A,(DE) + ADD C + LD C,A + INC DE + CALL CALC_ADR + POP BC + DEC HL + LD (HL),#0 + JR FREE_PART_LOOP + + RET + +;------------------------------------------------ +; Variabelen en data gebied +;------------------------------------------------ + +INT_DOS: .dw 0 +INT_GAME: .dw INT_ROUTINE + +ADR: .dw 0x4000+260 ; waar staat het veld ???? + de rand +LINE: .db 10 + +FASTCOP: +BRON_X: .db 0,0 +BRON_Y: .db 0,2 +DOEL_X: .db 0,0 +DOEL_Y: .db 0 +DOEL_PAGE: .db 0 +NUM_X: .db 16,0 +NUM_Y: .db 16,0 + .db 0,0 +VDP_LOG: .db 0xD0 + +ALGCOP: .db 0,0,0,2,0,0,0,0,16,0,16,0,0,0,0xD0 + +TNKCOP: .db 0,0,160,2,0,0,0,0,16,0,16,0,0,0,0x98 + +TNKCOP_RI: .db 0,0,160,2,0,0,0,0,16,0,16,0,0,0,0x98 +TNKCOP_DN: .db 0,0,160,2,0,0,0,0,16,0,16,0,0,0,0x98 +TNKCOP_LT: .db 0,0,160,2,0,0,0,0,16,0,16,0,0,0,0x98 +TNKCOP_UP: .db 0,0,160,2,0,0,0,0,16,0,16,0,0,0,0x98 + +TANK_IMG: .db 0,0,96,3,224,0,0,3,32,0,32,0,0,0,0x98 +BUILD_IMG: .db 0,0,64,3,224,0,0,3,32,0,32,0,0,0,0x98 + +EMPTY: .db 160,0,0,3,208,0,24,0,32,0,32,0,0,0,0xD0 + +RADCOP: .db 192,0,128,0,192,0,128,1,65,0,65,0,0,0,0xD0 + + +POWER_BALK: .db 200,0,56,3,208,0,58,0,32,0,8,0,0,0,0xD0 +POWER_INFO: .db 200,0,40,3,208,0,58,0,32,0,8,0,0,0,0xD0 +POWER_COP: .db 208,0,58,0,208,0,58,0,32,0,8,0,0,0,0xD0 +HARV_BALK: .db 192,0,0,3,232,0,24,0,8,0,32,0,0,0,0xD0 +HARV_COP: .db 232,0,24,0,232,0,24,0,8,0,32,0,0,0,0xD0 + +ITEM_CANCEL: .db 208,0,120,3,200,0,96,0,48,0,8,0,0,0,0xD0 +CANCEL_COP: .db 208,0,96,3,200,0,72,0,48,0,32,0,0,0,0xD0 + +LIJN_COP: .db 0,0,0,3 + .db 64,0,31,0 + .db 112,0,1,0 + .db 0,0,0xD0 + +MENU_COP: .db 0,0,0,3 + .db 64,0,32,0 + .db 112,0,112,0 + .db 0,0,0xD0 + +PLOF_COP: .db 0,0,64,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +LETCOP: .db 0,0,128,3,0,0,0,0,8,0,8,0,0,0,0xD0 +LETCOP2: .db 0,0,136,3,0,0,0,0,8,0,8,0,0,0,0x98 + +CONCRETE_COP: .db 0,0,80,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0xD0 + +SHOOT0: + .db 128,0,0,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +SHOOT1: + .db 144,0,0,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +IMPACT0: + .db 192,0,0,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +COP_BSEL_1: + .db 192,0,64,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +COP_BSEL_2: + .db 224,0,64,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 +COP_BSEL_3: + .db 208,0,64,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 +COP_BSEL_4: + .db 240,0,64,2 + .db 0,0,0,0 + .db 16,0,16,0 + .db 0,0,0x98 + +BB_BUSY_COP: + .db 0,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0x98 + +BB_BLW_COP: + .db 32,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0xD0 + +BB_RED_COP: + .db 64,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0xD0 + +BB_X_COP: + .db 96,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0xD0 +BB_READY_COP: + .db 128,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0x98 + +BB_BLD_COP: + .db 0,0,64,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0x98 +BB_TNK_COP: + .db 0,0,96,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0x98 +BB_BLD2_COP: + .db 0,0,0,3 + .db 0,0,176,0 + .db 32,0,32,0 + .db 0,0,0x98 + +BB_MOVE_COP: + .db 224,0,0,3 + .db 0,0,176,0 + .db 32,0,32,0 + .db 0,0,0xD0 + +BB_STEPS_BAR: + .db 194,0,0,3 + .db 0,0,176,0 + .db 4,0,16,0 + .db 0,0,0xD0 +GRAY_ITEM: + .db 160,0,0,3 + .db 224,0,0,3 + .db 32,0,32,0 + .db 0,0,0xD0 +PUT_ITEM: + .db 224,0,0,3 + .db 208,0,24,0 + .db 32,0,32,0 + .db 0,0,0xD0 + +MENU_COM_ATT: + .db 0,0,32,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_RED_ATT: + .db 0,0,48,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_MOV: + .db 48,0,32,3 + .db 200,0,80,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_MOV: + .db 48,0,48,3 + .db 200,0,80,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_HRV: + .db 144,0,32,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_HRV: + .db 144,0,48,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_COM_RET: + .db 192,0,32,3 + .db 200,0,96,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_RET: + .db 192,0,48,3 + .db 200,0,96,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_STP: + .db 0,0,40,3 + .db 200,0,88,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_STP: + .db 0,0,56,3 + .db 200,0,88,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_REP: + .db 48,0,40,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_REP: + .db 48,0,56,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_UPG: + .db 96,0,40,3 + .db 200,0,80,0 + .db 48,0,8,0 + .db 0,0,0xD0 +MENU_RED_UPG: + .db 96,0,56,3 + .db 200,0,80,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_CAN: + .db 144,0,40,3 + .db 200,0,96,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_CLN: + .db 144,0,56,3 + .db 200,0,72,0 + .db 48,0,8,0 + .db 0,0,0xD0 + +MENU_COM_SWP: + .db 200,0,58,0 + .db 200,0,58,1 + .db 48,0,46,0 + .db 0,0,0xD0 + +MENU_COM_SW2: + .db 200,0,72,0 + .db 200,0,72,1 + .db 48,0,32,0 + .db 0,0,0xD0 + +SWAP: .db 0 + +OFFSET: .db 1,1 ; zorg dat er altijd een rand #0xomeen is ! +MAXSET: .db 53,53 ; vierkant veld !! is max offset + breedt + +BALK: .db 0 ; xlengte + .db 0 ; ylengte + .dw 0 ; xbegin + .dw 0 ; ybegin + +STOP: .db 0 ; anders dan 0 is stop +MSTOP: .db 0 + +MBUSY: .db 0 +TNKADR: .dw 0 + +B_BALK_TYPE: .db 0 +B_BALK_NR: .db 0 +T_BALK_NR: .db 0 +BB_WAIT: .db 0 +BB_UP_DOWN: .db 0 + + +RADAR: .db 0 ; niet elke keer updaten !! +VDPADR: .dw 0x0300+100 + +MS_COUNT: + .db 0 ; multiple select counter + +TEMPLATE_TNK: + .ds TANK_DATA ; template voor toevoegen tank ! + +TEMP_HARV: ; ; templates per tank + .db 2 ; speed byte + .db 0,140 ; ATTACK / SHIELD + .db 60 +TEMP_SIEGE: + .db 2 + .db 190,150 + .db 19 +TEMP_TANK: + .db 2 + .db 175,140 + .db 15 +TEMP_QUAD: + .db 4 + .db 160,120 + .db 10 +TEMP_TRIKE: + .db 8 + .db 155,80 + .db 7 +SPRATR: +MOUSEY: .db 96 +MOUSEX: .db 128 +MOUSE_SHAPE: .db 0 + .db 4 + + .db 0,0,4,4 + .db 0,0,8,8 + .db 0,0,12,12 + + .db 0,0,32,16 ; build vlak sprite + .db 0,0,32,20 + .db 0,0,32,24 + .db 0,0,32,28 + .db 0,0,32,32 + .db 0,0,32,36 + + .db 0,0,36,40 + .db 0,0,40,44 + .db 0,0,44,48 + .db 0,0,48,52 + +SPRKLR_WHT: + .db 15,15,15,15,15,15,15,15 + .db 15,15,15,15,15,15,15,15 +SPRKLR_RD: + .db 10,10,10,10,10,10,10,10 + .db 10,10,10,10,10,10,10,10 + +BB_TYPES: .db 1,4,6,4,6,4,1,4,255 ; zie bb + +BB_SIZE: .db 0 ; 1, 4(2) of 6(3) + +BB_BLOCKED: .db 0 ; 1 is blocked 0 is vrij ! +BB_OUT_RANGE: .db 0 + +BB_SERIE: + .db 0,0,0,0,0,0,0 ; Hoe groot en welke spritesvoor BB + +BBB_VALUE: + ; 1 = aanwezig , build step, current step + ; 2 = busy with building + ; 3 = ready building + ; 0 = niet aanwezig + + .db 1,64,63,2 ; status, steps, current, money neede + .db 1,8,7,24 + .db 1,2,1,80 + .db 1,16,15,10 + .db 1,2,1,90 + .db 0,4,3,14 + .db 0,8,7,1 + .db 0,2,1,2 + +TBB_VALUE: + .db 0,16,15,0 ; 5types units + .db 0,8,7,0 + .db 0,4,3,0 + .db 0,2,1,0 + .db 0,2,1,0 ; BBB +13 + +ETB_VALUE: + .db 1,16,15,0 + .db 1,8,7,0 + .db 1,4,3,0 + .db 1,2,1,0 + .db 0,2,1,0 ; BBB + 18 + +UPG_LEV_BLD: .db 0 ; total upg level +UPG_LEV_UNT: .db 0 ; MAX 4 ? +IS_UNT_UPGRADING: .db 0 ; 1 per keer aub +IS_BLD_UPGRADING: .db 0 + +ITEMSELECTED: + .db 0 ; 0- 31 is enemy tanks of buildin + ; ; 32-63 is eigen tanks of building + ; ; 64-? item van build balk +SELECTED: + .db 0 ; is er een tank geselecteerd +HAS_SELECT: + .db 0 ;er is multiple select gedaan +MSELECT_ON: + .db 0 ; er zijn tanks geselecteerd +TOTAL_SELECT: .db 0 ; nax 25 in selectie ! + +CURSOR_TYPE: + .db 0 ; ?? + +FIRE_BUTTONS: .db 0 + +BUT_PRESSED: .db 0 ; bit 0 pressed but1 + ; ; bit 1 pressed but2 + +RADARS: + .dw RAD_DUMMY + .dw RAD_SIEGE + .dw RAD_TANK + .dw RAD_QUAD + .dw RAD_TRIKE + +RAD_DUMMY: .db 100,100 + +RAD_SIEGE: ; altijd op 100,100 eindigen + .db -1,-3,0,-3,1,-3 + .db -2,-2,-1,-2,0,-2,1,-2,2,-2 + .db -3,-1,-2,-1,-1,-1,0,-1,1,-1,2,-1,3,-1 + .db -3,0,-2,0,-1,0,1,0,2,0,3,0 + .db -3,1,-2,1,-1,1,0,1,1,1,2,1,3,1 + .db -2,2,-1,2,0,2,1,2,2,2 + .db -1,3,0,3,1,3 + .db 100,100 + +RAD_TANK: ; altijd op 100,100 eindigen + .db -1,-2,0,-2,1,-2 + .db -2,-1,-1,-1,0,-1,1,-1,2,-1 + .db -2,0,-1,0,1,0,2,0 + .db -2,1,-1,1,0,1,1,1,2,1 + .db -1,2,0,2,1,2 + .db 100,100 + +RAD_QUAD: ; altijd op 100,100 eindigen + .db -1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1,100,100 + +RAD_TRIKE: ; altijd op 100,100 eindigen + .db -1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1,100,100 + +RAD_HARVB: ; altijd op 100,100 eindigen + .db -1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1 + .db 0,-2,2,0,0,2,-2,0,2,-2,2,2,-2,2,-2,-2,100,100 + +RAD_HARVR: ; altijd op 100,100 eindigen + .db -1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1 + .db 0,-2,2,0,0,2,-2,0,2,-2,2,2,-2,2,-2,-2 + .db 0,-3,3,0,0,3,-3,0,3,-3,3,3,-3,3,-3,-3 + .db 0,-4,4,0,0,4,-4,0,4,-4,4,4,-4,4,-4,-4 + .db 0,-5,5,0,0,5,-5,0,5,-5,5,5,-5,5,-5,-5 + .db 0,-6,6,0,0,6,-6,0,6,-6,6,6,-6,6,-6,-6 + .db 0,-7,7,0,0,7,-7,0,7,-7,7,7,-7,7,-7,-7,100,100 + +SPICE_RAD: + .dw -1*4+-1*256 + .db 17 + .dw 0+-1*256 + .db 18 + .dw 1*4+-1*256 + .db 19 + .dw -1*4+0*256 + .db 20 + .dw 0+0 + .db 16 + .dw 1*4+0*256 + .db 21 + .dw -1*4+1*256 + .db 22 + .dw 0*4+1*256 + .db 23 + .dw 1*4+1*256 + .db 24 + +FACTORY_DEPLOY: + .dw (0*4)+0*256,(1*4)-1*256 + .dw (2*4)-1*256,(3*4)-1*256,(4*4)+0*256,(4*4)+1*256 + .dw (3*4)+2*256,(2*4)+2*256,(1*4)+2*256,(0*4)+256 + .dw (-1*4)+0,0-1*256,(1*4)-2*256,(2*4)-2*256 + .dw (3*4)-2*256,(4*4)-1*256,5*4,(5*4)+1*256,(4*4)+2*256 + .dw (3*4)+3*256,(2*4)+3*256,(1*4)+3*256,(0*4)+2*256 + .dw (-1*4)+1*256,100,100 + + +QUAKE: .db 0 ; nummer van slachtoffer + +PLAYFIELD: .db 0 ; cursor binnen area 3 = 1 + +MOUSE_OFF: .db 0 ; AAN OF UIT +MOUSE_USE: .db 0 ; " """""""" +MOUSE_PORT: .db 0 ; PORT 1 OF 2 +MOUSE_WAIT1: .db 0 ; WAIT CYCLE 1 +MOUSE_WAIT2: .db 0 ; WAIT CYCLE 2 + + +DIS_MONEY: .dw 200 +MONEY: .dw 300 ; maal 10 +MONEY_POS: .db 204,4 +MONEY_CHAR: .db 0,0,0,0,0 + +FPS_OUT: .dw 0 + +DEEL2: .dw 10000 +DEEL1: .dw 1000 + .dw 100 +DEEL0: .dw 10 + .dw 1 + +ISTEXT: .db 0 + +TEXTADR: .dw 0 +TEXTTAB: + .dw TEXT_TNK1 + .dw TEXT_TNK2 + .dw TEXT_TNK3 + .dw TEXT_TNK4 + .dw TEXT_MENU1 + .dw TEXT_OUTOFMONEY + +TEXT_TNK1: .str "YES SIR >>" + .db 255 +TEXT_TNK2: .str "YO >>" + .db 255 +TEXT_TNK3: .str "AFFIRMITIVE.." + .db 255 +TEXT_TNK4: .str "ACKNOWLEDGED" + .db 255 +TEXT_MENU1: .str "DOME ALPHA 3" + .db 255 +TEXT_OUTOFMONEY: .str "NOT ENOUGH FUNDS..." + .db 255 + +PDATA_1: + .db 4,0x78 ; CONTREL/FLAG + .db 7,1 ; MOET!!! + .db 8,0 ; DIV INIT + .db 9,0 ; ST LOW + .db 10,0 ; ST HI + .db 11,0x0 ; EI LOW + .db 12,0x0 ; EI HI + .db 16,0xF0 ; 16 Khz PLAY + .db 17,0x51 ; 16 Khz PLAY + .db 18,255 ; VOL ADPCM + .db 24,8 ; ADPCM AAN + .db 7,0x60 ; IETS (0xA0 IS PLAY) + +DEST_OFFSET: + .db 0,0,1,0,0,1,1,1 + .db 2,0,2,1,0,2,1,2,2,2 + .db 3,0,3,1,3,2,0,3,1,3,2,3,3,3 + .db 4,0,4,1,4,2,4,3,0,4,1,4,2,4,3,4,4,4 + + +PLOF_COUNT: .db 0 +PLOF_TABEL: + .db 0,0,0 ; X Y nummer + .db 0,0,0 ; nummer = 0 > leeg einde rij + .db 0,0,0 ; nummer = 1 > plof aanwezig + .db 0,0,0 + .ds 240 ; genoeg ruimte ? + +EVENT: .db 0 + +EVENTHANDLER: + .dw BUILD + .dw UPDATE + .dw CHKXY + .dw RADAR_UPDATE + .dw AI + .dw ALGEMEEN + +CPYTT: ; copy tank tabel + .ds 144*2 ; indeling is 0 1 of 2 en dan ix+ + .db 0,0 ; voor de afronding z.w.m.z. en dus 40 un + + +P_BUILD: .dw 0 ; pointer naar huidig geslect building + +EXTR_B_DATA: + .ds 8 ; steen + .db 2,2,255,154,0,0,0,0 ; windtrap + .db 3,2,255,154,0,0,0,0 ; ref + .db 2,2,255,154,0,0,0,0 ; silo + .db 3,2,255,154,0,0,2,0 ; factory + .db 2,2,255,154,0,0,0,0 ; radar + .db 1,1,255,154,0,0,0,0 ; tower + .db 2,2,255,154,0,0,3,0 ; const yard. + .ds 8 + +BUILDINGS: + .db 4 + +BUILDING1: + .db 1,7,25,13,2,2,200,150 ; yard coors + .db 0b00000000 + ; 0 ; repair bitje + ; 0 ; is upgrading.. + .db 0 ; cur. upgrade level + .db 3 ; max. upgrade level + .db 0 ; upgrade status + .db 0 ; refinery bezet ja/nee + + .ds BUILD_DATA*24 + + ;--------------------------------------------- +BUILDING_RED: + .db 26,7,50,46,2,2,255,100,0,0,0,0,0 + .db 27,1,53,46,2,2,255,100,0,0,0,0,0 + .db 28,4,49,49,3,2,255,100,0,0,0,0,0 + + .ds BUILD_DATA*22 ; 50 stuks max. + ; 25 blauw / 25 rood + +TNK_CNT_BLW: .db 2 +TNK_CNT_RED: .db 2 + +BLD_CNT_BLW: .db 1 +BLD_CNT_RED: .db 0 + +DED_CNT_BLW: .dw 0 +DED_CNT_RED: .dw 0 + +.area _DATA diff --git a/src/init/0module.mk b/src/init/0module.mk new file mode 100644 index 0000000..55499e4 --- /dev/null +++ b/src/init/0module.mk @@ -0,0 +1,20 @@ + +INIT_NAME := init +INIT_SRC := $(PATH_SRC)/$(INIT_NAME) +INIT_BIN := $(PATH_BIN)/$(INIT_NAME) +INIT_HEX := $(INIT_BIN)/$(INIT_NAME).hex +INIT_COM := $(INIT_BIN)/$(INIT_NAME).com +INIT_RELS := $(INIT_BIN)/$(INIT_NAME).rel +INIT_CODE := $(INIT_SRC)/$(INIT_NAME).asm + +$(INIT_BIN): + $(call mod_mkdir,$(INIT_BIN)) + +$(INIT_BIN)/%.rel: $(INIT_SRC)/%.asm | $(INIT_BIN) + $(call mod_compile_asm,$@,$<) + +$(INIT_HEX): $(INIT_RELS) + $(call mod_link_asm_dos,$(INIT_HEX),$(INIT_RELS)) + +$(INIT_COM): $(INIT_HEX) + $(call mod_hex2com,$(INIT_HEX),$(INIT_COM)) diff --git a/src/init/init.asm b/src/init/init.asm new file mode 100644 index 0000000..49b69d5 --- /dev/null +++ b/src/init/init.asm @@ -0,0 +1,716 @@ +;------------------------------------ +; DOME +; +; (c) 1998 PARAGON Productions +; +; DOME.COM +; +;------------------------------------ +DOS .equ 0x5 +D_OPEN .equ 0x0F +D_SETDMA .equ 0x1A +D_READ .equ 0x27 +D_CLOSE .equ 0x10 + +.area _CODE + JP START + + .db 0x0D ; type dome.com + .db 0x0D,0x0A + .str "DOME (c) 1999 PARAGON Productions" + .db 0x0D,0x0A + .db 0x1A ; Einde txt +TXT_END: + + .ds 0x4000 ;-TXT_END (XASM CRACHED HIEROP !!!) + +TXT_HELP: + .str "GETTING STATED WITH DOME" + .db 0x0A,0x0D + .db 0x0A,0x0D + .str "GAME STORY:" + .db 0x0A,0x0D + .db 0x0A,0x0D + .str "The evel harkonon are at war with" + .db 0x0A,0x0D + .str "the shadow attridis....." + .db 0x0A,0x0D + .db 0x0A,0x0D + .str "that is the true story of dome." + .db 0x0A,0x0D + .db 0x0A,0x0D + .str "GAME PLAY:" + .db 0x0A,0x0D + .db 0x0A,0x0D + .str "Very simple" + .db 0x0A,0x0D,0x1D + +TXT_COM: + .str " " + .db 0x0A,0x0D + .str "Below you see a listing of all the" + .db 0x0A,0x0D + .str "extra options you can give to DOME." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /? = This text. " + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /HELP = This functions give's you the entire " + .db 0x0A,0x0D + .str " help of DOME." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /TEST = START'S ONLY LEVEL 001 WITH MIN. INIT." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /MOUSEx = x is 1 or #2 so you can skip the mouse search." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /FMPAC = DOME asume's you have a FM-PAC." + .db 0x0A,0x0D + .str " And forces if moonsound drv is found to reload." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " /NO_SCSI= DOME don't seek's thoug your MSX-SCSI config." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + .str " PS : Your are also able to type in small letter." + .db 0x0A,0x0D + .str " " + .db 0x0A,0x0D + + .str "_______________DOME_______________" + .db 0x0A,0x0D + .str " PARAGON PRODUCTIONS (C)1999" + .db 0x0A,0x0D,0x1D + + +TXT_DOME_LIB: .str "LOADING : DOME_LIB...." + .db 0x1D +TXT_DOME_MUS: .str "LOADING : DOME_MUSDRV." + .db 0x1D +TXT_DOME_BIOS: .str "LOADING : DOME_BIOS..." + .db 0x1D +TXT_DOME_LOADER:.str "LOADING : DOME_LOADER." + .db 0x1D +TXT_READY: .str "Ready" + .db 0x0A,0x0D,0x1D + +START: + LD A,(0x0080) ; aantal tekens + OR A + CALL NZ,GET_COM ; 0 tekens = geen tekst + + CALL CHK_DISK + + CALL CHK_MUS + + LD A,(0x0080) + + LD HL,#TXT_COM + BIT 0,A + JP NZ,PUT_TXT ; TEXT COMMMENT'S + + BIT 1,A + JP NZ,PRT_HELP ; DOME HELP MOET GRAFISH + + LD HL,#TXT_DOME_LIB + CALL PUT_TXT + +; LD HL,#DOME_LIB +; CALL INIT_LIB + + LD HL,#TXT_READY + CALL PUT_TXT + + LD HL,#TXT_DOME_BIOS + CALL PUT_TXT + + LD HL,#BIOS + LD DE,#0x0100 + LD A,#0 ; 254 + LD BC,#0x3000 + CALL LOAD + + LD HL,#TXT_READY + CALL PUT_TXT + + LD HL,#TXT_DOME_LOADER + CALL PUT_TXT + + LD HL,#LOADER + LD DE,#0x8000 + LD A,#0 ; 255=+CLOSE + LD BC,#0x3000 + CALL LOAD + + LD HL,#TXT_READY + CALL PUT_TXT + + ld e,#"0" + ld c,#0x02 + call DOS + + ld e,#0x0A + ld c,#0x02 + call DOS + ld e,#0x0D + ld c,#0x02 + call DOS + + LD DE,#0x8000 +DUMP_LOOP: + LD A,(DE) + PUSH DE + CALL PUTHEX + POP DE + INC DE + LD A,D + CP #0x81 + JR NZ,DUMP_LOOP + + DI ; VEILIGHEID + JP 0x8000 + +DOME_LIB: .str "DOME 000" +BIOS: .str "BIOS DAT" +LOADER: .str "LOADER DAT" +WAVEDRV: .str "WAVEDRV COM" + + + + +PUTHEX: + PUSH AF + RRCA + RRCA + RRCA + RRCA + CALL HEXSUB + POP AF +HEXSUB: + AND #0x0F + ADD A,#'0' + CP #'9'+1 + JR C,HEXS1 + ADD A,#'A'-10-'0' +HEXS1: + LD E,A + LD C,#2 + CALL DOS + RET + +CHK_DISK: + LD A,#0 ;CURRENT + LD C,#0x1B + CALL DOS + + RET + +CHK_MUS: + LD HL,#TXT_DOME_MUS + CALL PUT_TXT + CALL CHK_OPL4 + + LD HL,#TXT_READY + JP NZ,PUT_TXT + + ;CALL CHK_MUSIC + LD HL,#TXT_READY + JP PUT_TXT + +CHK_OPL4: + LD A,#5 + OUT (0xC6),A ; reg 5 ( FM) + PUSH BC + POP BC + LD A,#3 + OUT (0xC5),A ; SET OPL4 REGISTER SET + PUSH BC + POP BC + LD A,#2 + OUT (0x7E),A ; REG 2 (WAVE) + PUSH BC + POP BC + IN A,(0x7F) ; + CPL + OR A + RET Z ; GEEN OPL4 DUS OOK GEEN DRV + + XOR A ; get mapper variable table + LD D,#4 + LD E,#1 + CALL 0xFFCA + LD A,C ; XOR A ??? + LD BC,#2 + ADD HL,BC + LD A,(HL) + + CP #6 ; MUSIC NEED 4 SEGMENTS !!!!!!!!!!!!!!!!!!! + JP NC,CHK_OPL4_CONT ; MEER DAN 6 + + CALL CHECK_IF_INST + RET NZ ; GEEN DRV + + LD HL,#WAVEDRV + CALL RELEASE_DRV +CHK_OPL4_EXIT: + LD A,#1 + OR A ; NZ ANDERS MUSIC OOK + RET + +CHK_OPL4_CONT: + LD A,(0x0080) + BIT 3,A + LD HL,#WAVEDRV + JR NZ,LOAD_DRV ; GEWWON NOG EEN KEER LADEN + + CALL CHECK_IF_INST + JR Z,CHK_OPL4_EXIT + LD HL,#WAVEDRV +LOAD_DRV: + LD IY,#0x0080 + LD A,(IY) + PUSH AF + + LD (IY),#7 + LD (IY),#" " + LD (IY),#"/" + LD (IY),#"I" + LD (IY),#">" + LD (IY),#"N" + LD (IY),#"U" + LD (IY),#"L" + + LD DE,#0x0100 + LD BC,#0x1000 + LD A,#0 + CALL LOAD + + CALL 0x0100 ; WAVE DRV + + POP AF + LD (0x0080),A + RET + +RELEASE_DRV: + LD IY,#0x0080 + LD A,(IY) + PUSH AF + + LD (IY),#7 + LD (IY),#" " + LD (IY),#"/" + LD (IY),#"R" + LD (IY),#">" + LD (IY),#"N" + LD (IY),#"U" + LD (IY),#"L" + + LD DE,#0x0100 + LD BC,#0x1000 + LD A,#0 + CALL LOAD + + CALL 0x0100 ; WAVE DRV + + POP AF + LD (0x0080),A + RET + + + +; Check if replayer is installed +; output: if nz=0 not installed +; if z=1 installed + +CHECK_IF_INST: + LD HL,#ID_FB04 + LD DE,#0xFB04+21 + LD B,#5 +CHECK_IF_INST_LP: + LD A,(DE) + CP (HL) + RET NZ + INC HL + INC DE + DJNZ CHECK_IF_INST_LP + RET + +ID_FB04:.str "MBTSR" ; If this is on address FB04h+21 + +;===== + +GET_COM: + LD IY,#0x0080 + LD HL,#0x0081 + LD B,(IY) + LD (IY),#0 +GET_COM_LP: + LD A,(HL) + INC HL + + CP #"?" + JR NZ,GET_COM_CONT + SET 0,(IY) ; ACTIVATE HELP HIGHEST PIRIOTIJD +GET_COM_CONT: + + PUSH BC + PUSH HL ; DOOR INC HL GA DOOR NAAR NEXT CMD + CP #"/" + CALL Z,GET_COM_STR + POP HL + POP BC + + DJNZ GET_COM_LP + RET + +;===== + + +GET_COM_STR: + LD DE,#GET_COM_TAB +GET_COM_STR_LP: + LD A,(HL) + LD C,A + + LD A,(DE) + OR A + JR Z,GET_COM_BIT ; NEXT COM + + CP #255 ; GEEN COMMANDO FOUND + RET Z + + CP C + JR Z,GET_COM_STR_CONT ; A + + ADD #32 + CP C + JR Z,GET_COM_STR_CONT ; a + +GET_COM_STR_NOT_LP: + LD A,(DE) + INC DE + OR A + JR NZ,GET_COM_STR_NOT_LP ; ZOEK TOT VOLGEND COM + + INC DE + + POP BC ; CALL STACK + POP HL ; ; org ADR OF CMD + PUSH HL + PUSH BC + + JR GET_COM_STR_LP + +GET_COM_STR_CONT: + INC HL + INC DE + JR GET_COM_STR_LP + +;---- + +GET_COM_BIT: + INC DE + LD A,(DE) + DEC A + JR Z,COM_HELP + DEC A + JR Z,COM_DOS2 + DEC A + JR Z,COM_FMPAC + DEC A + JR Z,COM_NO_SCSI + DEC A + JR Z,COM_MOUSE + DEC A + JR Z,COM_NO_TXT + RET +COM_HELP: + SET 1,(IY) + RET +COM_DOS2: + SET 2,(IY) + RET +COM_FMPAC: + SET 3,(IY) + RET +COM_NO_SCSI: + SET 4,(IY) + RET +COM_MOUSE: + SET 5,(IY) + LD A,(HL) + CP #"1" + RET Z + SET 6,(IY) + RET +COM_NO_TXT: + SET 7,(IY) + RET + + +GET_COM_TAB: + .str "HELP" + .db 0,1 ; /HELP = COM.. 0=LAST + .str "TEST" + .db 0,2 + .str "FMPAC" + .db 0,3 + .str "NO_SCSI" + .db 0,4 + .str "MOUSE" + .db 0,5 + .str "NO_TXT" + .db 0,6,255 + + + +PRT_HELP: + LD HL,#TXT_HELP + JP PUT_TXT + + + +PUT_TXT: + LD A,(HL) + CP #0x1D + RET Z + LD E,A + LD C,#2 + PUSH HL + CALL DOS + POP HL + INC HL + JR PUT_TXT + + +; IF A=NOT 254 OR A=NOT 255 THEN +; +; HL= FILE NAME (LOAD_BIN) +; DE= DMA-ADR +; A= HEADER TRACH +; BC= LENGTE +; ELSE +; HL= FILE NAME (LOAD_LIB) +; DE= DMA-ADR +; +; IF A=255 THEN CLOSE_LIB +; END + + +LOAD: + CP #254 ; CLOSE LIB ON EXIT + JR C,LOAD_BIN ; KLEINER DAN + + EX AF,AF + PUSH DE ; ADR + + CALL SEARCH_FILE ; if found lengte in HL + + POP DE ; ADR + PUSH HL ; LENGT + CALL SETDMA ; DE is adres + + POP HL + CALL READ + + EX AF,AF + CP #255 + RET NZ + JP CLOSE + +;--------- + +LOAD_BIN: + PUSH BC + PUSH AF + PUSH DE + + CALL PUT_NAM_FCB + CALL OPEN + + POP DE + CALL SETDMA + + POP HL + LD L,H ; KAN ?? + LD H,#0 + CALL READ ; kan dit ?? + + POP HL + CALL READ ; op oude DMA adres ??? + CALL CLOSE ; ja !! raar he ?! + RET + +; Zoek file op in directory en stel record number in +; In: HL: adres te laden file-naam +; DE: adres directory +; Uit: HL: lengte file +; A: 0 indien gelukt, 255 indien mislukt + +SEARCH_FILE: + LD DE,#DIRECTORY ; eerste2 bytes zijn aantal files +SEARCH_FILE0: + + PUSH HL ; adres naam v.d. file + PUSH DE ; adres directory + + CALL CMP_STR + OR A + JR Z,SEARCH_FILE1 + + POP DE + LD HL,#11 + 2 + 3 + ADD HL,DE + EX DE,HL ; DE = positie in directory + POP HL + JR SEARCH_FILE0 + +SEARCH_FILE1: ; HL = adres in directory + EX DE,HL + + LD E,(HL) + INC HL + LD D,(HL) ; laad lengte + INC HL + PUSH DE + + LD DE,#FCB + 33 + LD BC,#3 + LDIR ; Record Number naar FCB + + XOR A ; drive ?? + LD (DE),A + + POP HL ; lengte in HL + + POP DE + POP DE + RET + +CMP_STR: + LD B,#11 +CMP_STR1: + LD A,(DE) + CP (HL) + RET NZ + INC HL + INC DE + DJNZ CMP_STR1 + XOR A + RET + + +; Laad directory +; In: HL: Adres filename +; DE: Bestemmingsadres directory + +INIT_LIB: + LD DE,#DIRECTORY + + PUSH DE + PUSH DE + + CALL PUT_NAM_FCB ; put HL in FCB + CALL OPEN + + cp #0 + jr z,INIT_LIB_OK + + LD HL,#FILE_ERROR + LD B,#10 + CALL PUT_TXT + +INIT_LIB_OK: + + POP DE + CALL SETDMA ; destination is DIRECTORY + + LD HL,#2 + CALL READ + + POP HL ; In BC aantal files + LD C,(HL) + INC HL + LD B,(HL) + + LD HL,#0 + LD DE,#11 + 3 + 2 ; lengte entry = name + +CALC_LENGTH: + ADD HL,DE + DEC BC + LD A,B + OR C + JR NZ,CALC_LENGTH + + CALL READ ; lees directory struct + + RET + +;========================================================================= +;========================================================================= +;=================== SUBS ============================================== +;========================================================================= +;========================================================================= + + +PUT_NAM_FCB: ; ; In: HL = file name pointer + LD DE,#FCB+1 + LD BC,#0x0B ; Out: A = drive name (0 = def., 1 = + LDIR ; Cng: HL,DE BC,AF + XOR A + LD (FCB),A ; (DRVNAM) must be valid + RET + +SETDMA: + LD C,#D_SETDMA ; DE=ADR + JP DOS +OPEN: + LD DE,#FCB + LD C,#D_OPEN + CALL DOS + LD HL,#0x01 + LD (FCB+14),HL ; Record length = 1 byte + DEC L + LD (FCB+33),HL + LD (FCB+35),HL ; Current record number = 0 + RET + +READ: + LD DE,#FCB + LD C,#D_READ ; HL=NR BYTES + JP DOS + +CLOSE: + LD DE,#FCB + LD C,#D_CLOSE + JP DOS + +FILE_ERROR: .str " NOT FOUND" ; 10 len + .db 0x0A,0x0D + +FCB: .db 0 +FILENAME: .str " " +BLOCK: .dw #00 +RECORDLENGTH: .dw #00 +FILELENGTH: .dw #00,#00 +SYSTEMVAR: .dw #00,#00,#00,#00,#00,#00 + .db 0 +RECORDNR: .dw #00,#00 + + +DIRECTORY: + .db 0 ; 7 BYTES PER FILE OF 11+3+2 suckS + ; ; NAAM - LENGTE - REC.NUM + +.area _DATA