#include "USGARD.H" ;Usgard header file (definitions) SCRWIDTH = 128 SCRHEIGHT = 64 .org 0 .db "January 3nd ",0 ;<-Name that appears on shell. ; __________________________________________ ; / \ ;| SET FIRST VALUES OF VARIABLES AS NEEDED | ; \__________________________________________/ ld a, 4 ld (liv), a ; ___________________________________________________________________ ; / \ ;| FIRST EXECUTION OF CODE........BEGIN GAME...THEN QUIT TO ZSHELL | ; \___________________________________________________________________/ ld hl, $8C40 set 0, (hl) call &intro udnd: ld a, (liv) dec a ld (liv), a ret z sub a ld (Velocity), a ld a, 5 ld (Velocity2), a ld a, 3 ld (Jumping), a ld a, (ud) cp 6 ld a, 8 ;\__When you first draw the screen ld (temp4), a ;/ no trimming necessary. sub a ld (scrolling), a ld (mine), a ld (wml), a ld (wmr), a ld (Super_Jump), a inc a ld (sintclk), a ld (spj), a ld (jsj), a ld (ud), a inc a ld (ctc), a ld a, 13 ld (pow), a ld a, 219 ld (tim), a ld a, 150 ld (tim2), a call &Draw_Beg ;<---Draw the begging of the level call &mrv ;<--show it in video_mem (prev. graph_mem) call &set_guy ;<---draws your guy and sets his position call &bot_stats ld hl, &IntTime call INT_INSTALL ;################################################################## ;# Okay, now the first screen has been drawn, begin the game loop # ;################################################################## ld a, 18 ;\ ld (XRow), a ; \ ld a, 128 ; \__New coordinates are finnished ld (XRow2), a ; / preparing for scrolling sub a ; / (NOT USED FOR THE GUYS COORDINATES!) ld (XRow3), a ;/ ld (v_up), a Top_Get2: ;<---Key loop. ld a, (wml) ;\ dec a ; \ call z, &mv_left ; \__Should we move ld a, (wmr) ; / horizontally? dec a ; / call z, &mv_right ;/ ld a, (Update_Jump_Fall) ;\ dec a ; \ call z, &Move_Along_Y ; )-Should we move vertically? ld a, (Jumping) ; / dec a ;/ call z, &Check_Hold ;Are you really still holding down the ;jump button(s)? Let's check :) ld a, (ud) sub 5 ;cp 5 jp z, &quit dec a ;cp 6 jp z, &udnd dec a ;cp 7 call z,&udie ld a, (drtt) cp 2 call z, &bot_stats ld a, (drtt2) cp 2 call z, &bot_stats2 call GET_KEY cp K_GRAPH jp z, &mrv2 call OTH_ARROW bit 4, a call z, OTH_SHUTDOWN call OTH_ARROW bit 7, a call z, OTH_PAUSE ;call z, &pause call OTH_ARROW bit 3, a call z, &Jump call OTH_ARROW bit 5, a call z, &Jump call OTH_ARROW bit 6, a jr z, quit ret z ;man! ok, biya! =) ld a, (ud) cp 5 jr z, quit cp 6 jp z, &udnd Top_Get: ld a, (ud) cp 5 jr z, quit cp 6 jp z, &udnd ld a, (rds) dec a call z, &fxscr jp &Top_Get2 ; done with checking last key-press, now ; check the next one. quit: call INT_CLEAN ret Check_Hold: call OTH_ARROW bit 3, a ret z call OTH_ARROW bit 5, a ret z sub a ld (Jumping), a ld (Super_Jump), a ret ; ################################################################ ;################################################################## ;### ### ;### THIS PORTION OF THE CODE IS SET ASIDE FOR THE NEW ### ;### DETECTION ROUTINES BUILT AS OF 11/18/97 ### ;### ### ;### If "can_move" is set to 0 you CAN move, if it ### ;### is set to 1 you CANNOT move. This is for ALL dirrections. ### ;### ### ;################################################################## ; ################################################################ ; _____________________________________________________________________ ;/ \ Check_Left: ;<---Complete Routine which will check if you can go left. ; NO setup required, output will be in "can_move" ld a, 1 ; /__ Preset for checking to the left. ld (can_move), a ; \ (next 3 lines), this saves a jr and ; another routine. ld a, (man_x2) ;To save time, check to see if you are and a ;on the very right of the screen. ret z ;If so you CANNOT ever move left. sub a ; /__ Assuming you can move, unless ld (can_move), a ; \ something is detected. ;##################################################################### ;# Check pixels first.... # ;##################################################################### ld a, (man_x2) ;<--Actual position of guy (x-coordinate) dec a ;<--Actual minus one ld (temp2), a ;<--Save that in the checking variable. ;This is because the routine starts every cycle ;by inc'ing "temp2" (x-coordinate) ld a, (man_y2) ;<--Actual position of guy (y-coordinate) ld b, a ;\ ld a, 63 ; }- Sprite routine and pixel routine use sub b ;/ differnt coordinates (top -> bot. vs ; bot. -> top). We are now reversing this. ld (temp3), a ;<--Save new y-coordinate in "temp3". Left_Pixel_Check_Top: ; * Actual Routine to Check Pixels on Left * ld a, (man_y2) ;\ ld b, a ; \ ld a, 58 ; \ sub b ; \___Are you done checking pixels? ld b, a ; / If so you passed, no flag is ld a, (temp3) ; / needed to be set. cp b ; / ret z ;/ dec a ;/___Move down one row (you will be moving in ld (temp3), a ;\ the y dirrection to check) ld c, a ;\ ld a, (temp2) ; }--Setup registers for FIND_PIXEL checking. ld b, a ;/ ROM_CALL(FIND_PIXEL) ;\ ld de, GRAPH_MEM ; \ add hl, de ; }--Actually check pixel. and (hl) ;_/ jr z, Left_Pixel_Check_Top ;<---No pixel, jump back up and move ; y-coordinate for new check. ;############################################################## ;# You failed the pixel test. Go on to the matrix test..... # ;############################################################## sub a ;\__Reset it so you CAN move, unless bad block ld (can_move), a ;/ is found.... ld a, (MANX1) ;\___Set initial x-coordinate in matrix. ld (AXRow), a ;/ ld a, (MANX2) ; \ cp 1 ; \ jr nz, Fix_X_Matrix ; \__Are you all the way to the left? ld a, (AXRow) ; / If so you need to look in the block dec a ; / one to the left... ld (AXRow), a ; / Fix_X_Matrix: ld a, (MANY1) ;\__Set the initial y-coordinate in the matrix. ld (AYCol), a ;/ call &Determine_Block_Type ;<---Get block type. ld a, (MANY2) ;\ cp 4 ; >-If you y-posision in block is 1,2 or 3 ret c ;/ you are only in one vertical block. ld a, (MANY1) ;\ inc a ;<---But if you arn't you need to check block ld (AYCol), a ; one up from last..... (top of your head is call &Determine_Block_Type ; in this block) ; #################################################################### ;# # ;# Matrix checking for the left is complete. If you hit a block the # ;# matrix checking routine has already triggered the respective flag. # ;# # ; #################################################################### ret ;<---You're done checking to the left!!!! ;\____________________________________________________________________/ ; _____________________________________________________________________ ;/ \ Check_Right: ; Complete Routine which will check if you can go right. ; NO setup required, output will be in "can_move" sub a ; /__ Assuming you can move, unless ld (can_move), a ; \ something is detected. ;##################################################################### ;# Check pixels first.... # ;##################################################################### ld a, (man_x2) ;<--Actual position of guy (x-coordinate) add a, 9 ;<--Add 9 to check colum to right of Globber :) ld (temp2), a ;<--Save that in the checking variable. ;This is because the routine starts every cycle ;by inc'ing "temp2" (x-coordinate) ld a, (man_y2) ;<--Actual position of guy (y-coordinate) ld b, a ;\ ld a, 62 ; }- Sprite routine and pixel routine use sub b ;/ differnt coordinates (top -> bot. vs ; bot. -> top). We are now reversing this. ld (temp3), a ;<--Save new y-coordinate in "temp3". Right_Pixel_Check_Top: ; * Actual Routine to Check Pixels on Right * ld a, (man_y2) ;\ ld b, a ; \ ld a, 58 ; \ sub b ; \___Are you done checking pixels? ld b, a ; / If so you passed, no flag is ld a, (temp3) ; / needed to be set. cp b ; / ret z ;/ dec a ;/___Move down one row (you will be moving in ld (temp3), a ;\ the y dirrection to check) ld c, a ;\ ld a, (temp2) ; }--Setup registers for FIND_PIXEL checking. ld b, a ;/ ROM_CALL(FIND_PIXEL) ;\ ld de, GRAPH_MEM ; \ add hl, de ; }--Actually check pixel. and (hl) ;_/ jr z, Right_Pixel_Check_Top ;<---No pixel, jump back up and move ; y-coordinate for new check. ;############################################################## ;# You failed the pixel test. Go on to the matrix test..... # ;############################################################## sub a ;\__Reset it so you CAN move, unless bad block ld (can_move), a ;/ is found.... ld a, (MANX1) ;\ inc a ; >--Set initial x-coordinate in matrix. ld (AXRow), a ;/ ld a, (MANX2) ; \ cp 8 ; \ jr nz, Fix_X_Matrix2 ;\__Are you all the way to the right? ld a, (AXRow) ; / If so you need to look in the block inc a ; / one to the right... ld (AXRow), a ; / Fix_X_Matrix2: ld a, (MANY1) ;\__Set the initial y-coordinate in the matrix. ld (AYCol), a ;/ call &Determine_Block_Type ;<---Get block type. ld a, (MANY2) ;\ cp 4 ; >-If you y-posision in block is 1,2 or 3 ret c ;/ you are only in one vertical block. ld a, (MANY1) ; inc a ;<---But if you arn't you need to check block ld (AYCol), a ; one up from last..... (top of your head is call &Determine_Block_Type ; in this block) ; #################################################################### ;# # ;# Matrix checking for the right is complete. If you hit a block the # ;# matrix checking routine has already triggered the respective flag. # ;# # ; #################################################################### ret ;<---You're done checking to the right!!!! ;\____________________________________________________________________/ ; _____________________________________________________________________ ;/ \ Check_Up: ; Complete Routine which will check if you can go up. ; NO setup required, output will be in "can_move" ld a, 1 ;/___Assume you are at the top of the screen ld (can_move), a ;\ at first. ld a, (man_y2) ;\ and a ; )--Are you at the top of the screen? ret z ;/ If so you can't jump. sub a ; /__ Assuming you can move, unless ld (can_move), a ; \ something is detected. ;##################################################################### ;# Check pixels first.... # ;##################################################################### ld a, (man_x2) ;<--Actual position of guy (x-coordinate) dec a ;<--Decrease by one (loop inc's at beginning) ld (temp2), a ;<--Save that in the checking variable. ;This is because the routine starts every cycle ;by inc'ing "temp2" (x-coordinate) ld a, (man_y2) ;<--Actual position of guy (y-coordinate) ld b, a ;\ ld a, 62 ; }- Sprite routine and pixel routine use sub b ;/ differnt coordinates (top -> bot. vs ; bot. -> top). We are now reversing this. ld (temp3), a ;<--Save new y-coordinate in "temp3". Up_Pixel_Check_Top: ; * Actual Routine to Check Pixels on Top * ld a, (man_x2) ;\ add a, 8 ; \ ld b, a ; \___ Are you done moving to the right?? ld a, (temp2) ; / cp b ; / ret z ;/ inc a ;/___Move right one row (you will be moving in ld (temp2), a ;\ the x dirrection to check) ld b, a ;\ ld a, (temp3) ; }--Setup registers for FIND_PIXEL checking. ld c, a ;/ ROM_CALL(FIND_PIXEL) ;\ ld de, GRAPH_MEM ; \ add hl, de ; }--Actually check pixel. and (hl) ;_/ jr z, Up_Pixel_Check_Top ;<---No pixel, jump back up and move ; x-coordinate for new check. ;############################################################## ;# You failed the pixel test. Go on to the matrix test..... # ;############################################################## sub a ;\__Reset it so you CAN move, unless bad block ld (can_move), a ;/ is found.... ld a, (MANX1) ;\__Set initial x-coordinate in matrix. ld (AXRow), a ;/ ld a, (MANY1) ;\__Set the initial y-coordinate in the matrix. dec a ld (AYCol), a ;/ ld a, (MANY2) ;\__Where exactly are you in matrix block?? cp 3 ;/ jr c, NNTI ;if you don't need to increment, don't (no need to i) ld a, (AYCol) ;\ inc a ; )-At top or over block, increment check block ld (AYCol), a ;/ by one. NNTI: call &Determine_Block_Type ;<---Get block type. and a ; )-If you've already hit something, quit now. ret nz ;/ ld hl, AXRow ;\ inc (hl) ; move one block to the right call &Determine_Block_Type ;<---Get the second block type. ret ; #################################################################### ;# # ;# Matrix checking for the top is complete. If you hit a block the # ;# matrix checking routine has already triggered the respective flag. # ;# # ; #################################################################### ;\____________________________________________________________________/ ; _____________________________________________________________________ ;/ \ Check_Down: ; Complete Routine which will check if you can go down. ; NO setup required, output will be in "can_move" ld a, 1 ; /__ If you've died, you don't want ld (can_move), a ; \ to keep on falling!!!! ld a, (man_y2) ;\ cp 50 ; )-Are you too far down on the screen? If jp nc, &uftd ;/ So you have died (sink-hole) ; uftd = U have FALLEN TO your DEATH sub a ; /__ Assuming you can move, unless ld (can_move), a ; \ something is detected. ;##################################################################### ;# Check pixels first.... # ;##################################################################### ld a, (man_x2) ;<--Actual position of guy (x-coordinate) ; dec a ;<--Decrease by one (loop inc's at beginning) ; ld (temp2), a ;<--Save that in the checking variable. ld B, A ;This is because the routine starts every cycle ;by inc'ing "temp2" (x-coordinate) ld a, (man_y2) ;<--Actual position of guy (y-coordinate) ld c, a ;\ ld a, 57 ; }- Sprite routine and pixel routine use sub c ;/ differnt coordinates (top -> bot. vs ; bot. -> top). We are now reversing this. ; ld (temp3), a ;<--Save new y-coordinate in "temp3". ld C, A call FIND_PIXEL ld DE, GRAPH_MEM add HL, DE ld C, A ld B, 8 Bottom_Pixel_Check_Top: ld A, (HL) ;Load VIDEO_MEM information and C ;Test pixel using bitmask C jr nz, Bottom_Matrix_Check ;Black? -> Matrix test rrc C ;Next pixel to right jr nc, Bottom_Pixel_Check_Top_1 ;Carry? (1->128) inc HL ;Yup, increase VIDEO_MEM info Bottom_Pixel_Check_Top_1: djnz Bottom_Pixel_Check_Top ;do this 8 times ret ; ld a, (man_x2) ;\ ; add a, 8 ; \ ; ld b, a ; \___ Are you done moving to the right?? ; ld a, (temp2) ; / ; cp b ; / ; ret z ;/ ; inc a ;/___Move right one row (you will be moving in ; ld (temp2), a ;\ the x dirrection to check) ; ld b, a ;\ ; ld a, (temp3) ; }--Setup registers for FIND_PIXEL checking. ; ld c, a ;/ ; ROM_CALL(FIND_PIXEL) ;\ ; ld de, GRAPH_MEM ; \ ; add hl, de ; }--Actually check pixel. ; and (hl) ;_/ ; jr z, Bottom_Pixel_Check_Top ;<---No pixel, jump back up ;and move x-coordinate for new ;check. ;############################################################## ;# You failed the pixel test. Go on to the matrix test..... # ;############################################################## Bottom_Matrix_Check: sub a ;\__Reset it so you CAN move, unless bad block ld (can_move), a ;/ is found.... ld a, (MANX1) ;\__Set initial x-coordinate in matrix. ld (AXRow), a ;/ ld a, (MANY1) ;\__Set the initial y-coordinate in the matrix. ; inc a ld (AYCol), a ;/ ld a, (MANY2) ;\__Where exactly are you in matrix block?? cp 1 ;/ jr nc, NNTI2 ;if you don't need to increment, don't (no need to) ld a, (AYCol) ;\ dec a ; )-At top or over block, increment check block ld (AYCol), a ;/ by one. NNTI2: call &Determine_Block_Type ;<---Get block type. ld a, (can_move) ;\ and a ; )-If you've already hit something, quit now. ret nz ;/ ld a, (AXRow) ;\ inc a ; )--Move over one to check the second upper ld (AXRow), a ;/ block. call &Determine_Block_Type ;<---Get the second block type. ret ; #################################################################### ;# # ;# Matrix checking for the top is complete. If you hit a block the # ;# matrix checking routine has already triggered the respective flag. # ;# # ; #################################################################### ;\____________________________________________________________________/ ; ____________________________________________________________________ ;/ \ chkok: ;this is a TEMPORARY label, CHANGE ROUTINES SO THIS IS NOT ;NEEDED ANYMORE!!!! Determine_Block_Type: ;<---Determine block type: you can or cannot ; move though. call &get_m_info ;<---Get the block # from the level matrix. and a ret z cp 26 ;\ ret z ; \ cp 27 ; \ ret z ; \ cp 28 ; \ ret z ; \ cp 65 ; \ ret z ; \ cp 66 ; \ ret z ; \ cp 67 ; \ ret z ; \ cp 24 ; \ ret z ; \ cp 25 ; \ ret z ; \ cp 18 ; \ ret z ; \ cp 19 ; \ ret z ; \ cp 8 ; \ ret z ; \ ________________ cp 7 ; \ | | ret z ; \ | These are all | cp 6 ; \| blocks you CAN | ret z ; /| move though | cp 62 ; / |________________| ret z ; / cp 63 ; / ret z ; / cp 64 ; / ret z ; / cp 41 ; / ret z ; / cp 42 ; / ret z ; / cp 43 ; / ret z ; / cp 55 ; / ret z ; / cp 56 ; / ret z ; / cp 57 ; / ret z ; / cp 58 ; / ret z ; / cp 59 ; / ret z ; / cp 60 ; / ret z ;/ ld a, 1 ; ld (can_move), a ;<--The block you hit was NOT flagged as ret ; something you can move though, you CANNOT ; move in this dirrection. ;\_____________________________________________________________________/ pause: call INT_REMOVE ld hl, VIDEO_MEM call &clr_hl ; <- Nice routine I made that clears memory at hl call &bot_stats ld hl, $032D ld de, paus ld ($8333), hl ld hl, (PROGRAM_ADDR) add hl, de call D_ZM_STR ld de, $091C ;;;;; call &draw_text ; ld de, $1C1C ; call &draw_text ; ld de, $221C ; call &draw_text ; ld de, $281C ; call &draw_text ;;;;; pause_top: call GET_KEY cp K_EXIT call z, OTH_EXIT cp K_ENTER jr z, pause_end cp K_SECOND call z, OTH_SHUTDOWN jr pause_top pause_end: call &mrv call &dr_guy ld hl, &IntTime call INT_INSTALL ret ;######################## ;# Sinking sequence # ;######################## uftd: ld a, 6 ld (temp4), a uftt: ld hl, VIDEO_MEM ;######### ld (DEST_ADDR), hl ;################### call &mrv ld hl, y21 ld de, (PROGRAM_ADDR) add hl, de ld a, (man_x2) ld b, a ld a, (man_y2) ld c, a #fncall PSPR_W ld hl, y12 ld de, (PROGRAM_ADDR) add hl, de ld a, (man_x2) ld b, a ld a, (man_y2) add a, 8 ld c, a #fncall PSPR_W call &bot_stats2 call &wait2 ld a, (temp4) dec a ld (temp4), a ld a, (man_y2) inc a ld (man_y2), a cp 55 jr nc, ufdie ld hl, y21 inc hl ld (temp3), hl ld hl, temp4 ld de, (temp3) ld bc, 1 ldir ld hl, y12 inc hl ld (temp3), hl ld hl, temp4 ld de, (temp3) ld bc, 1 ldir jr uftt ufdie: ;you fell to your death. call &mrv call &wait2 call &wait2 call &wait2 call &wait2 call &wait2 udie: call INT_REMOVE ld a, 6 ld (ud), a ld a, 6 ld (temp1), a ld hl, &y21 inc hl ld (temp3), hl ld hl, temp1 ld de, (temp3) ld bc, 1 ldir ld hl, &y12 inc hl ld (temp3), hl ld hl, temp1 ld de, (temp3) ld bc, 1 ldir ret Start_Fall: ;Starts falling, sets up variables... ld a, (Jumping) cp 3 ret z ld a, 3 ld (Jumping), a ld a, 0 ld (Velocity), a ld a, 3 ld (Velocity2), a ret ; ____________________________________________________________________ ;/ \ Jump: ld a, (Super_Jump) dec a ret z ld a, (Jumping) ;\ Are you currently jumping? If so you can't and a ; ) jump again. jr nz, Jump2 ;/ Re_Jump: ;Bounces back here if you do super-jump call &Check_Up ; / ld a, (can_move) ;/__Are you at the top of the screen or is dec a ;\ a block ontop of you? If so you can't ret z ; \ jump either. ld a, 20 ;\__Physics! This controls how fast you ld (Velocity), a ;/ start jumping up. :) ld a, 10 ld (Velocity2), a ; ################################################################## ;#################################################################### ;## ;## Velocity and Height DO NOT act like they would in the real world. ;## If they did you there would be not reason for the Height variable ;## because Velocity would zero-out with gravity after a certain amount ;## of time T. I use a different method.... ;## ;## First, I take 27-Velocity (I might change the 27 to another #) ;## and I'll call that V' (not the derivitive). This number is then ;## handeled by interrupt. I will store V' in "Velocity2." ;## ;## The interrupt will decrease Velocity2 until it reaches zero. When it ;## does the interrupt will call either the jumping or falling routine ;## (to make Globber actually jump or fall respectively). As you can see ;## a high Velocity will make a small Velocity2 and the jumping/falling ;## routine will be called more often. Basically I have achieved faster ;## movements when Velocity is set to a bigger number. ;## ;## So how does gravity get into this equation? When going up (when the ;## actual jumping routine is called) the Velocity will be dec'ed. ;## Eventually Velocity will hit zero and then you will stop going up ;## and start going down. Down has inverse properties. Bescause gravity ;## is a force being added to the object, Globber, Velocity will ;## increase with time. ;## ;#################################################################### ; ################################################################## ld a, 2 ;\__Well, you are jumping now, so set the ld (Jumping), a ;/ variable to say so. :) ;\_____________________________________________________________________/ Jump2: ld a, (Jumping) cp 2 ret nz ld a, (Velocity) cp 10 ret c call OTH_ARROW bit 5, a ret nz call OTH_ARROW bit 3, a ret nz ld a, 20 ld (Velocity), a ld a, 10 ld (Velocity2), a ld a, 1 ld (Super_Jump), a ret mv_left: ld a, 0 ld (wml), a ld a, 1 ld (srol), a ld a, (man_x2) cp 1 ret c call &Check_Left ld a, (can_move) cp 1 ret z ld a, (man_x2) dec a ld (man_x2), a ld a, 2 ld (ctc), a ld a, 1 ld (rds), a ld a, (MANX2) dec a ld (MANX2), a cp 0 jr nz, sml1 ld a, 8 ld (MANX2), a ld a, (MANX1) dec a ld (MANX1), a sml1: ld a, (Jumping) cp 2 ret z call &Check_Down ld a, (can_move) cp 1 ret z call &Start_Fall ;Starts falling, sets up variables. ret mv_right: ;routine to move your guy (and possibly the screen) right. ld a, 0 ld (wmr), a ld a, 2 ld (srol), a call &Check_Right ld a, (can_move) cp 1 ret z ld a, 2 ld (ctc), a ld a, (MANX2) inc a ld (MANX2), a cp 9 jr nz, smr1 ld a, 1 ld (MANX2), a ld a, (MANX1) inc a ld (MANX1), a smr1: ld a, (man_x2) cp 96 jp z, &mv2 inc a ld (man_x2), a ld a, 2 ld (ctc), a ld a, 1 ld (rds), a ld a, (Jumping) cp 2 ret z call &Check_Down ld a, (can_move) cp 1 ret z call &Start_Fall ;Starts falling, sets up variables. ret fxscr: call &mrv call &guy_look call &dr_guy ld a, 0 ld (rds), a ret guy_look: ld a, (man_t) inc a ld (man_t), a cp 10 jr nz, sts ld a, 1 ld (man_t), a ld a, (man_t3) cp 2 jr z, sts2 ld a, (man_t2) inc a ld (man_t2), a cp 4 jr nz, sts ld a, 2 ld (man_t3), a ld (man_t2), a sts: ret sts2: ld a, 1 ld (man_t2), a ld (man_t3), a jr sts scrll: ;<---scrolling routine, scroll graph_mem ld a, 1 ld (scrolling), a ;================================= ld hl,$8641+$380-1 ;old $8641+$400-1 sla (hl) ;================================= ld b,$e0 ;$ff old sl1: dec hl rl (hl) djnz sl1 ;================================= ld b,0 sl2: dec hl rl (hl) djnz sl2 ;================================= ld b,0 sl3: dec hl rl (hl) djnz sl3 ;================================= ld b,0 sl4: dec hl rl (hl) djnz sl4 ;================================= ld a, 0 ld (scrolling), a ret mv2: ;<-routine used to scroll the screen right. call &scrll ;<-scoll graph_mem left one column of pixels. ;(note: pixels wrap for new images will have ;to replace what was there, including blank ;spaces!) ld a, 1 ;\ ld (YCol), a ; \__Start at the bottom of the screen. ld a, 48 ; / ld (YCol2), a ;/ ld a, (XRow3) ;\ inc a ; \ ld (XRow3), a ; \__Reset x coordinates, including trim- ld a, (XRow2) ; / factor and x-coordinate to draw from. dec a ; / ld (XRow2), a ;/ ld a, (XRow3) ;\___Set the amount you want to trim off. ld (temp4), a ;/ tp2: ld a, (XRow) ld (AXRow), a ld a, (YCol) ld (AYCol), a call &get_m_info ;<-what are we gonna draw? call &ld_spr2 ;<-load it preparing to trim stuff. call &Dra ;<-draw it in graph_mem (to reduce ld a, (YCol2) ;\ sub 8 ; \ ld (YCol2), a ; \___increase the high-low level ld a, (YCol) ; / (vertical shift) inc a ; / ld (YCol), a ;/ cp 9 ;\__Have you hit the end of the screen??? jr nz, tp2 ;/ ld a, (XRow2) ;\ cp 120 ; >--Have you hit a new column of cells? call z,&rst ;/ If so reset XRow* variables call &mrv ;<---ok, you've scrolled the screen, ; redrawn ;new stuff, now show it (load graph_mem into ; video_mem) call &guy_look call &dr_guy ;<---and now redraw the guy. ld a, (Jumping) cp 2 ret z call &Check_Down ld a, (can_move) cp 1 ret z call &Start_Fall ;Starts falling, sets up variables. ret ;<---Yeah! you did it, now return. rst: ;<--new cell of blocks, reset reliable ; variables. ld a, (XRow) ;\ inc a ; >--points to cell of blocks (column) ld (XRow), a ;/ ld a, 128 ;\___points to actual x-cor value (for ld (XRow2), a ;/ drawing the sprite) ld a, 0 ;\__How much of the sprite do I actually ld (XRow3), a ;/ draw? (used for trimming.) ret bot_stats2: call &cl_bot bot_stats: ld hl, $3937 ld de, stats2 ld ($8333), hl ld hl, (PROGRAM_ADDR) add hl, de call D_ZM_STR ld hl, VIDEO_MEM ld (DEST_ADDR), hl ld hl, b1 ld de, (PROGRAM_ADDR) add hl, de ld a, 1 ld b, a ld a, 57 ld c, a #fncall PSPR_W ld hl, b2 ld de, (PROGRAM_ADDR) add hl, de ld a, 9 ld b, a ld a, 57 ld c, a #fncall PSPR_W ld hl, b4 ld de, (PROGRAM_ADDR) add hl, de ld a, 13 ld b, a ld a, 59 ld c, a #fncall PSPR_W ld hl, b3 ld de, (PROGRAM_ADDR) add hl, de ld a, 28 ld b, a ld a, 57 ld c, a #fncall PSPR_W ld hl, b4 ld de, (PROGRAM_ADDR) add hl, de ld a, 36 ld b, a ld a, 59 ld c, a #fncall PSPR_W ld hl, GRAPH_MEM ld (DEST_ADDR), hl call &power call &time call &minerals call &lives ld a, 1 ld (drtt), a ld (drtt2), a ret power: ld bc, $3928 ld (CURSOR_X), bc ld a, (pow) #fncall DM_A_DEC ret time: ld bc, $3974 ld (CURSOR_X), bc ld a, (tim) #fncall DM_A_DEC ret rdsc: ld a, 1 ld (drtt), a ld a, 2 ld (drtt2), a ret lives: ld bc, $390C ld (CURSOR_X), bc ld a, (liv) #fncall DM_A_DEC ret minerals: ld bc, $3952 ld (CURSOR_X), bc ld a, (mine) #fncall DM_A_DEC ret IntTime: ; push bc ;\ ; push de ; \___Gotta push the registers so ; push hl ; / I don't loose any information... ; push af ;/ ld a, (sintclk) inc a ld (sintclk), a cp 2 jr z, wm cp 3 jr nz, wm3 ld a, 1 ld (sintclk), a wm3: call OTH_ARROW bit 1, a jr nz, wmr2 ld a, 1 ld (wml), a wmr2: call OTH_ARROW bit 2, a jr nz, wm ld a, 1 ld (wmr), a wm: ;################################################ ;# Jumping/Falling portion of the interrupt.... # ;################################################ ld a, (Jumping) ; If you are and a ; just sitting there, waiting jr z, Timer_Interrupt ; for the jump button to be released, cp 1 ; or even hovering, your velocity won't jr z, Timer_Interrupt ; be changing and you won't be moving up cp 4 ; or down so you can skip this portion jr z, Timer_Interrupt ; of the interrupt. ld a, (Velocity2) ;\ cp 21 ; )-Is it time to jump or fall? jr nc, Skip_Jump_Fall ;/ If not skip this part.... ld a, 1 ;\ ld (Update_Jump_Fall), a ; )-Safest if done outside interrupt. ld a, (Jumping) cp 3 jr z, SFV ;Skip to the other fix of velocity ld a, (Velocity) dec a ld (Velocity), a jr nz, SFUV ;skip to not fixing update velocity. ld (Velocity), a ;/ You've stopped moving. ld (Velocity2), a ld (Super_Jump), a ;<-If you had done a super-jump it is done. ld a, 3 ;\ ld (Jumping), a ;/ You are now falling. jr Timer_Interrupt SFUV: ld b, a ld a, 30 sub b ld (Velocity2), a jr Timer_Interrupt SFV: ld a, (Velocity) cp 27 jr z, SFV2 inc a ld (Velocity), a SFV2: ld b, a ld a, 30 sub b ld (Velocity2), a jr Timer_Interrupt Skip_Jump_Fall: dec a ;\_ Decrease the secret timer... :) ld (Velocity2), a ;/ Timer_Interrupt: ;############################### ;# Timer Functions.... # ;############################### ld a, (tim2) dec a ld (tim2), a jr nz, ints2 ld a, 150 ld (tim2), a ld a, (tim) dec a ld (tim), a ld a, 2 ld (drtt), a ld a, (tim) cp 99 call z, &rdsc ld a, (tim) cp 9 call z, &rdsc ld a, (tim) and a jr nz, ints2 ld a, 7 ld (ud), a ints2: ; pop af ; pop hl ; pop de ; pop bc ret Move_Along_Y: ld a, (Jumping) cp 2 jr nz, Move_Down Move_Up: sub a ; Routine has been called, no ld (Update_Jump_Fall), a ; need to update screen anymore. call &Check_Up ld a, (can_move) ;\ cp 1 ; )-Stop jumping if you've hit a block or jr z, Stop_Jumping ;/ the top of the screen. ld a, 1 ;\__Note it so we redraw the screen. ld (rds), a ;/ ld a, (man_y2) dec a ld (man_y2), a ld a, (MANY2) inc a ld (MANY2), a cp 9 ; ret c ;No need to move the y-matrix counter...yet ld a, 1 ld (MANY2), a ld a, (MANY1) inc a ld (MANY1), a ret Stop_Jumping: sub a ;\ ld (Velocity), a ;/ You've stopped moving. ld a, 3 ;\ ld (Jumping), a ;/ You are now falling. ret Move_Down: sub a ; Routine has been called, no ld (Update_Jump_Fall), a ; need to update screen anymore. call &Check_Down ld a, (can_move) ;\ dec a ; )-Stop falling if you've hit a block or jr z, Stop_Falling ;/ the bottom fo the screen. ld a, 1 ;\__Note it so we redraw the screen. ld (rds), a ;/ ld a, (man_y2) inc a ld (man_y2), a ld a, (MANY2) dec a ld (MANY2), a ret nz ;No need to move the y-matrix counter...yet ld a, 8 ld (MANY2), a ld a, (MANY1) dec a ld (MANY1), a ret Stop_Falling: sub a ;\ ld (Velocity), a ;/ You've stopped moving. inc a ;\ ld (Jumping), a ;/ You are not stopped... did you let ; go of the jump buttons? call OTH_ARROW bit 3, a ;\ ret z ; \_Nope. bit 5, a ; / ret z ;/ sub a ;\ ld (Jumping), a ; )-Yep... :) ret ;/ set_guy: ; draws your guy and sets his position. ld a, 2 ld (MANX1), a ld a, 2 ld (MANY2), a sub a ld (man_x2), a ld a, 40 ld (man_y2), a ld a, 1 ld (MANX2), a ld a, 2 ld (MANY1), a ld (man_t), a ld (man_t2), a call &dr_guy ret dr_guy: ld hl, VIDEO_MEM ld (DEST_ADDR), hl ld hl, y11 ld a, (man_t2) cp 1 jr z, sgs ld hl, y21 cp 2 jr z, sgs ld hl, y31 sgs: ld de, (PROGRAM_ADDR) add hl, de ld a, (man_x2) ld b, a ld a, (man_y2) ld c, a #fncall PSPR_W ld hl, y12 ld a, (man_t2) cp 1 jr z, sgs2 cp 2 jr z, sgs2 ld hl, y32 sgs2: ld de, (PROGRAM_ADDR) add hl, de ld a, (man_x2) add a, 8 ld b, a ld a, (man_y2) ld c, a #fncall PSPR_W ld hl, GRAPH_MEM ld (DEST_ADDR), hl ret ; _______________________________________________________ ; / \ ;| Routine used to draw the level at the beginning :) | ; \_______________________________________________________/ Draw_Beg: ld hl, GRAPH_MEM call &clr_hl ; <- Nice routine I made that clears memory at hl ld hl, GRAPH_MEM ld (DEST_ADDR), hl ld a, 2 ld (XRow), a ld a, 1 ld (YCol), a ld a, 48 ld (YCol2), a sub a ld (XRow2), a D_R2: ld a, (XRow) ld (AXRow), a ld a, (YCol) ld (AYCol), a call &get_m_info call &ld_spr2 call &Dra ld a, (YCol) inc a cp 8 jr z, next_x ld (YCol), a ld a, (YCol2) sub 8 ld (YCol2), a jr D_R2 next_x ld a, 1 ld (YCol), a ld a, 48 ld (YCol2), a ld a, (XRow) inc a cp 18 ret z ld (XRow), a ld a, (XRow2) add a, 8 ld (XRow2), a jr D_R2 Dra: ld a, (XRow2) ld b, a ld a, (YCol2) cp 56 ret nc ld c, a call &ClipSprite ret mrv: ld hl, GRAPH_MEM ld de, VIDEO_MEM ld bc, 896 ldir ret mrv2: ld hl, VIDEO_MEM ld de, GRAPH_MEM ld bc, 1024 ldir call INT_REMOVE ret ld_spr2: ld hl, &sb cp 0 ret z ld hl, &s01 cp 1 ret z ld hl, &s02 cp 2 ret z ld hl, &s03 cp 3 ret z ld hl, &s04 cp 4 ret z ld hl, &s05 cp 5 ret z ld hl, &s06 cp 6 ret z ld hl, &s07 cp 7 ret z ld hl, &s08 cp 8 ret z ld hl, &s09 cp 9 ret z ld hl, &s10 cp 10 ret z ld hl, &s11 cp 11 ret z ld hl, &s12 cp 12 ret z ld hl, &s13 cp 13 ret z ld hl, &s14 cp 14 ret z ld hl, &s15 cp 15 ret z ld hl, &s16 cp 16 ret z ld hl, &s17 cp 17 ret z ld hl, &s18 cp 18 ret z ld hl, &s19 cp 19 ret z ld hl, &s20 cp 20 ret z ld hl, &s21 cp 21 ret z ld hl, &s22 cp 22 ret z ld hl, &s23 cp 23 ret z ld hl, &s24 cp 24 ret z ld hl, &s25 cp 25 ret z ld hl, &s26 cp 26 ret z ld hl, &s27 cp 27 ret z ld hl, &s28 cp 28 ret z ld hl, &s29 cp 29 ret z ld hl, &s30 cp 30 ret z ld hl, &s31 cp 31 ret z ld hl, &s32 cp 32 ret z ld hl, &s33 cp 33 ret z ld hl, &s34 cp 34 ret z ld hl, &s35 cp 35 ret z ld hl, &s36 cp 36 ret z ld hl, &s37 cp 37 ret z ld hl, &s38 cp 38 ret z ld hl, &s39 cp 39 ret z ld hl, &s40 cp 40 ret z ld hl, &s41 cp 41 ret z ld hl, &s42 cp 42 ret z ld hl, &s43 cp 43 ret z ld hl, &s44 cp 44 ret z ld hl, &s45 cp 45 ret z ld hl, &s46 cp 46 ret z ld hl, &s47 cp 47 ret z ld hl, &s48 cp 48 ret z ld hl, &s49 cp 49 ret z ld hl, &s50 cp 50 ret z ld hl, &s51 cp 51 ret z ld hl, &s52 cp 52 ret z ld hl, &s53 cp 53 ret z ld hl, &s54 cp 54 ret z ld hl, &s55 cp 55 ret z ld hl, &s56 cp 56 ret z ld hl, &s57 cp 57 ret z ld hl, &s58 cp 58 ret z ld hl, &s59 cp 59 ret z ld hl, &s60 cp 60 ret z ld hl, &s61 cp 61 ret z ld hl, &s62 cp 62 ret z ld hl, &s63 cp 63 ret z ld hl, &s64 cp 64 ret z ld hl, &s65 cp 65 ret z ld hl, &s66 cp 66 ret z ld hl, &s67 ret clr_hl: ld (hl), 0 ld d, h ld e, l ld bc, 1023 inc de ldir ret cl_bot: ld hl, VIDEO_MEM+896 ld (hl), 0 ld d, h ld e, l ld bc, 127 inc de ldir call &bot_stats ret get_m_info: ld hl, &level_1 ld a, (AXRow) dec a jr z, FirstLine ld b, a ld de, 7 ; <--- 7 is the width of the matrix Looper: add hl, de djnz Looper FirstLine: ld a, (AYCol) dec a ld e, a add hl, de ld a, (hl) ld (spr), a ret intro: call CLEARLCD ld hl, $0500 ld (CURSOR_ROW), HL ld hl, &Begin call D_ZT_STR ld de, $080F call &draw_text ld de, $0F0F call &draw_text ld de, $1B15 call &draw_text ld de, $2205 call &draw_text ld de, $2261 call &draw_text ld de, $2A13 call &draw_text ld de, $3125 call &draw_text call OTH_PAUSE ret draw_text: ld (CURSOR_X), DE call D_ZM_STR ret wait2: ld bc, 6000 call &wait ld bc, 6000 call &wait ld bc, 6000 call &wait ld bc, 6000 call &wait ret wait: dec bc ld a, b or c jr nz, wait ret #include "Csprite.H" ;sprite routine, thanx Andreas! :) #include "variable.h" ;definitions of variables used. #include "sprites.h" ;game sprites #include "levels.h" ;game levels #include "strings.h" ;strings like "paused" BitTable: .db $80,$40,$20,$10,$08,$04,$02,$01 .end