;*************************************************************************** ; SQUAREZ 2o15 BY LA1N (A RE(DE)MAKE OF THE WELL KNOWN FLASH GAME SQUARES) ;*************************************************************************** ; ; rene.bauer@zhdk.ch ; @ixistenz ; ; THIS IS A DEMAKE OF THE FLASH GAME SQUARES (2002)! ; I THOUGHT IT IS A SIMPLE GAMEMECHANIC HHH ; CODED IT AFTER AXE (ATARI 2600) AND INTELLIVISION GAME* ; * NOT YET RELEASED ; ; MECHANICS: MAKE AS MUCH POINTS AS POSSIBLE. ; COLLECT FOR POINTS. AVOID SQUAREZ! ; THERE CAN BE AT LEVEL7 UP TO 12 SQUAREZ ON SCREEN! ; DONT BE TOO GREEDY! ; ; YOU WILL FIND OLDER PROJECTS OF LA1N AT HTTP://WWW.LA1N.CH ; OR LOOK FOR OUR GAMEART AT HTTP://WWW.AND-OR.CH ; ; CREDITS GO TO RICHARDH FOR HIS MULTICARDS (THANKS!) ; ; TESTED: ; - PARAJVEv0.7 ; - VECTREX WITH MULTICARD ; ; Draw ; ; ^ -Y ; | ; | ; X-<---------->X+ ; | ; | ; \ +Y ; ;*************************************************************************** ; VERSIONS ;*************************************************************************** ; ; 0.82 working on bug over the edge ... not yet solved [20150106] ; 0.81 test on a real vectrex (problems with intensity 1 < not visible! at all) ; 0.8 long time test (PARAJVE) highscore 43 (made now 39pts in the lower levels) ; 0.77 add sound for level up (positive?) ; 0.76 bug fix appearing squares on levelup [20141227] ; 0.75 more comments ; 0.74 bug fix collision ; 0.73 more speed squares ; 0.72 going over the edge movement ; 0.71 different speeds ; 0.7 new sound effect system ; ;*************************************************************************** ; FOR THE REST OF US (PROGRAMMERS) ;*************************************************************************** ; ; Code is horrible, sorry. 90% of the code could be ; made much simpler. No entry for coders heaven .-) ; ; Infos about vectrec: http://www.vectrex.de ; ; Read: ; Most important commands (LD,ST, Tables(Index) ; http://www.playvectrex.com/designit/christumber/tutorial.htm#Indexed%20Addressing%20and%20Tables ; most important commands ; constants: equ { #, RAM: $c0f8 } ; load: ld[a|b|x|y] {8BIT: #3,RAM: $c0f8} > lld ; load index: lda 4,x | lda ,x+| lda,x++ ; store: st[a|b|x|y] {#3,RAM: $c0f8} ; transfer tfr [a|b|x|y] [a|b|x|y] (copy a to b) ; ; CodeSnipped: ; http://pelikonepeijoonit.net/files/vec/coders.html ; ; ALL IN ONE ; http://www.electronics.dit.ie/staff/ypanarin/Lecture%20Notes/K235-1/04%20Assembly%206800%20A.pdf ; http://www.maddes.net/m6809pm/appendix_a.htm ; ; All functions ; http://vectrexmuseum.com/share/coder/html/bios.htm#F511 ; ; Draw ; http://www.playvectrex.com/designit/chrissalo/linedrawing.htm ; "Print" ; http://vectrexprogramming.blogspot.co.uk/2014/11/converting-byte-value-to-ascii-in-6809.html ; Drawing Tool ; http://www.vectorzoa.com/vecdraw/vecdraw.html ; ; Collision Detection ; http://pelikonepeijoonit.net/files/vec/coleman.as9 ; ; Joystick ; http://vectrexmuseum.com/share/coder/html/joystick1.asm ; ; Sound ; http://www.playvectrex.com/designit/chrissalo/soundplaying.htm ; Sound effects ; http://vectrexmuseum.com/share/coder/other/TEXT/SOUND/SOUND.TXT ; Audio-Processor: AY (General Instruments) > Licenses Yamaha (YM (Intellivision, MSX) > Tracker ~ÊAtari ST) ; http://vectorgaming.proboards.com/thread/312/vectrex-sound-programming?page=1 ; http://en.wikipedia.org/wiki/General_Instrument_AY-3-8910 ; ; Random +Example ; http://vectrexmuseum.com/share/coder/html/bios.htm#F511 ; ; StartUP ; http://vectorgaming.proboards.com/thread/992/vectrex-programming-tutorial-tools-tech ; Forum ; http://vectrexprogramming.blogspot.co.uk ; INTERESTING: LDA [$C880] ( LDD ( VALUE($C880) ) ) include "VECTREX.I" ; vectrex function includes org $0000 ;*************************************************************************** ; CONSTANTTS (everything memory addresses, values, constants) ;*************************************************************************** state equ $C880 ; state ; 0: menu ; 1: intro ; 2: ingame ; 3: gameover level equ $C882 ; level ... 0-4 highscore equ $C884 score equ $C886 spritesnr equ $C888 ; nr 5 spritesyx equ $C888+2 ; x=1bytes, y=1byted > n*2 sprites[i] spritestype equ $C888+2+16*2 ; x=1bytes, y=1byted > n*4 sprites[i] spritesmove equ $C888+2+32*2 ; x=1bytes, y=1byted > n*4 sprites[i] ; temps sprites_for_var equ $c888+2+48*2 sprites_tmp_type equ $c888+2+48*2+1 sprites_tmp_move equ $c888+2+48*2+2 button_up equ $c888+2+48*2+3 soundeffect equ $c888+2+48*2+5 ; score as string - 10 bytes str_score equ $c888+2+48*2+8 counter_ms equ $c888+2+48*2+15 counter_sec equ $c888+2+48*2+16 counter_min equ $c888+2+48*2+17 str_x equ $c888+2+48*2+18 ;*************************************************************************** ; INIT ;*************************************************************************** db "g GCE LA1N", $80 ; 'g' is copyright sign dw music1 ; music from the rom db $F8, $50, $20, -$55 ; height, width, rel y, rel x ; (from 0,0) db "SQUAREZ 2o15",$80 ; some game information, ; ending with $80 db 0 ; end of game header ;*************************************************************************** ; CODE SECTION ;*************************************************************************** ; INIT ; start cartridge ; init lda #0 sta state lda #0 sta level lda #10 ; 42 sta highscore lda #0 sta score lda #12 ; 12 sta spritesnr ; tmp lda #0 sta soundeffect ; sprites yx lda #0 sta spritesyx+0 ; x sta spritesyx+1 ; x sta spritesyx+2 ; x sta spritesyx+3 ; x sta spritesyx+4 ; x sta spritesyx+5 ; x sta spritesyx+6 ; x sta spritesyx+7 ; x sta spritesyx+8 ; x sta spritesyx+9 ; x sta spritesyx+10 ; x sta spritesyx+11 ; x sta spritesyx+12 ; x sta spritesyx+13 ; x sta spritesyx+14 ; x sta spritesyx+15 ; x sta spritesyx+16 ; x sta spritesyx+17 ; x sta spritesyx+18 ; x sta spritesyx+19 ; x sta spritesyx+20 ; x sta spritesyx+21 ; x sta spritesyx+22 ; x sta spritesyx+23 ; x ; the sprites ; ; sprite 0 lda #-10 sta spritesyx+0 ; y lda #-10 sta spritesyx+1 ; x ; sprite 1 lda #10 sta spritesyx+2 ; y lda #10 sta spritesyx+3 ; x ; sprite 2 lda #-50 sta spritesyx+4 ; y lda #50 sta spritesyx+5 ; x ; sprite 3 lda #5 sta spritesyx+6 ; y lda #-75 sta spritesyx+7 ; x ; sprite 4 lda #-110 sta spritesyx+8 ; y lda #-100 sta spritesyx+9 ; x ; sprite 5 lda #88 sta spritesyx+10 ; y lda #-88 sta spritesyx+11 ; x ; sprite 6 lda #-88 sta spritesyx+12; y lda #18 sta spritesyx+13 ; x ; sprite 7 lda #122 sta spritesyx+14 ; y lda #24 sta spritesyx+15 ; x ; sprite 8 lda #-122 sta spritesyx+16 ; y lda #-44 sta spritesyx+17 ; x ; sprite 9 lda #32 sta spritesyx+18 ; y lda #124 sta spritesyx+19 ; x ; sprite 10 lda #32 sta spritesyx+20 ; y lda #124 sta spritesyx+21 ; x ; sprite 11 lda #32 sta spritesyx+22 ; y lda #124 sta spritesyx+23 ; x ; spritestype ; ; 0 player ; 1 bonbon ; 2 enemy ; lda #0 sta spritestype+0 lda #1 sta spritestype+1 lda #2 sta spritestype+2 lda #2 sta spritestype+3 lda #1 sta spritestype+4 lda #2 sta spritestype+5 lda #2 sta spritestype+6 lda #1 sta spritestype+7 lda #2 sta spritestype+8 lda #2 sta spritestype+9 lda #2 sta spritestype+10 lda #2 sta spritestype+11 ; spritesmove ; ; normal ; < 1 / > 2 ; ^ 3 / \/ 4 ; faster ; < 11 / > 12 ; ^ 13 / \/ 14 ; extremfast ; < 21 / > 22 ; ^ 23 / \/ 24 lda #1 sta spritesmove+0 lda #14 sta spritesmove+1 lda #1 sta spritesmove+2 lda #13 sta spritesmove+3 lda #11 sta spritesmove+4 lda #12 sta spritesmove+5 lda #13 sta spritesmove+6 lda #11 sta spritesmove+7 lda #14 sta spritesmove+8 lda #23 sta spritesmove+9 lda #22 sta spritesmove+10 lda #21 sta spritesmove+11 ; str score lda #120 sta str_score lda #0 sta str_score+1 lda #48 sta str_score+2 lda #48 sta str_score+3 lda #48 sta str_score+4 lda $80 sta str_score+5 ; button lda #0 sta button_up ; init music lda #1 ; one means, we are about to sta Vec_Music_Flag ; store it in appropriate RAM lda #1 sta soundeffect ; init joysticks etc lda #1 ; these set up the joystick sta Vec_Joy_Mux_1_X ; enquiries lda #3 ; allowing only all directions sta Vec_Joy_Mux_1_Y ; for joystick one lda #0 ; this setting up saves a few sta Vec_Joy_Mux_2_X ; hundred cycles sta Vec_Joy_Mux_2_Y ; don't miss it, if you don't ; need the second joystick! ;*************************************************************************** ; MAINLOOP ;*************************************************************************** ; here the cartridge program starts off main: ;*************************************************************************** ; INGAME: SOUNDEFFECTS ;*************************************************************************** ; ; sound/music effect system ; ; musixs & effects ; music1: standard short bling ; music2: some jap. sound ; music3: "marschmusik" ; music4: tštšttšttštšt ; music5: dšdodšdš ; music6: dšlolološlš ; music7: midage ; music8: positive some notes(short) ; music9: tatarutataturuta ; musica: dito ; musicb: bad end sound (short) ; musicc: positve short notes (short) ; musicd: ttttttššt ; ; waiting sound effects (only ingame!) ; do only these soundeffects ingame ; soundeffect ; 1: title ; 2: menu ; 3: game ; 4: gameover ; 5: bonbon ; 6: levelup ; ; play soundeffects lda soundeffect cmpa #0 beq no_soundeffect ; default sound effect ; music title lda soundeffect cmpa #1 bne no_music_title jsr DP_to_C8 ; DP to RAM ldu #music2 ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_title: ; music menu lda soundeffect cmpa #2 bne no_music_menu jsr DP_to_C8 ; DP to RAM ldu #music8 ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_menu: ; music game lda soundeffect cmpa #3 bne no_music_game jsr DP_to_C8 ; DP to RAM ldu #music8 ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_game: ; music gameover lda soundeffect cmpa #4 bne no_music_gameover jsr DP_to_C8 ; DP to RAM ldu #musicb ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_gameover: ; music bonbon lda soundeffect cmpa #5 bne no_music_bonbon jsr DP_to_C8 ; DP to RAM ldu #music_bonbon ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_bonbon: ; levelup lda soundeffect cmpa #6 bne no_music_levelup jsr DP_to_C8 ; DP to RAM ldu #music8 ; get some music, here music1 jsr Init_Music_chk ; and init new notes jmp music_start_now no_music_levelup: music_start_now: ; lda #0 ; sta soundeffect no_soundeffect: ; todo: more complex ; is a routine playing? doit ;*************************************************************************** ; INGAME: WAIT FOR RECAL ;*************************************************************************** ; wait recal .. jsr Wait_Recal ; Vectrex BIOS recalibration jsr Intensity_5F ; Sets the intensity of the ; vector beam to $5f jsr Delay_3 ; delay for 30 cycles lda #127 ; load 50 sta VIA_t1_cnt_lo ; 50 as scaling ;lda #2 ; load A with 6, dots - 1 ;sta Vec_Misc_Count ; set it as counter for dots ; ldx #dot_list ; load the address of dot_list ; ATTENTION POINTS ARE LIKE IN LOGO VW 20 RW 10 etc .. ;ldx #spritesyx ; jsr Dot_List ; Plot a series of dots ; lifes ; inc lifes ; lda spritesyx ; inca ; sta spritesyx ; inc spritesyx+4 ; state management ; dec level ;Decrement the number of ships left by 1 ; beq game_over ;Check if that was the last ship, and branch if it was ; jmp ingame ;game_over: ; game over ... ingame: ; ingame ;*************************************************************************** ; INGAME: PLAYER CONTROL JOYSTICK (DIRECTIONS & BUTTONS) ;*************************************************************************** ; player control / buttons jsr Read_Btns ; get button status lda Vec_Btn_State ; get the current state of all cmpa #$00 ; is a button pressed? beq no_buttons_pressed ; no, than go on ; button down ldb button_up cmpb #0 bne buttons_pressed_done ; start game ;ldu #string_joystick_right ;jsr Print_Str_yx ldb state cmpb #0 bne press_state_menu lda #2 sta state lda #0 sta level lda #0 sta score sta spritesyx sta spritesyx+1 lda #1 sta button_up lda #48 sta str_score+2 sta str_score+3 sta str_score+4 ; play music (set flag to wait for music) lda #1 ; one means, we are about to sta Vec_Music_Flag ; store it in appropriate RAM lda #2 sta soundeffect ; move demo sprites lda #80 sta spritesyx+2 lda #-80 sta spritesyx+4 ; level lda #0 sta level lda #0 sta counter_ms sta counter_sec sta counter_min jmp buttons_pressed_done press_state_menu: ; gameover > menu cmpb #3 bne press_state_gameover lda #0 sta state lda #1 sta button_up press_state_gameover: jmp buttons_pressed_done no_buttons_pressed: lda #0 sta button_up buttons_pressed_done: ; player control / joystick ; movement x lda #0 sta spritesmove ; joystick stuff jsr Joy_Digital lda Vec_Joy_1_X beq no_x_movement bmi left_move ; if negative, than left right_move: inc spritesyx+1 inc spritesyx+1 ;lda #2 ;sta spritesmove ;ldu #string_joystick_right ;jsr Print_Str_yx bra no_x_movement ; goto x done left_move: dec spritesyx+1 dec spritesyx+1 ;lda #1 ;sta spritesmove ;ldu #string_joystick_left ;jsr Print_Str_yx bra no_x_movement ; goto x done no_x_movement ; movement y lda Vec_Joy_1_Y ; load joystick 1 position beq no_y_movement ; if zero, than no y position bmi down_move ; if negative, than down up_move: inc spritesyx inc spritesyx ;lda #4 ;sta spritesmove ; otherwise up bra no_y_movement ; goto y done down_move: dec spritesyx dec spritesyx ;lda #3 ;sta spritesmove ; otherwise up bra no_y_movement ; goto y done no_y_movement: joystick_done: ;*************************************************************************** ; INGAME: MECHANICS MOVE SPRITES ;*************************************************************************** ; management / gamemechnics / update ... ; movement lda spritesnr sta sprites_for_var ldx #spritesyx ldy #spritesmove sprites_mechanics: pshs x pshs y ldb ,y ; y-movement cmpb #3 bne sprite_notgo_up dec ,x jmp sprites_mechanics_done sprite_notgo_up: cmpb #4 bne sprite_notgo_down inc ,x jmp sprites_mechanics_done sprite_notgo_down: ; 2x y-movement cmpb #13 bne sprite_notgo_up2x dec ,x dec ,x jmp sprites_mechanics_done sprite_notgo_up2x: cmpb #14 bne sprite_notgo_down2x inc ,x inc ,x jmp sprites_mechanics_done sprite_notgo_down2x: ; 3x y-movement cmpb #23 bne sprite_notgo_up2xx dec ,x dec ,x dec ,x jmp sprites_mechanics_done sprite_notgo_up2xx: cmpb #24 bne sprite_notgo_down2xx inc ,x inc ,x inc ,x jmp sprites_mechanics_done sprite_notgo_down2xx: ; x-movement lda ,x+ ; 1x x-movement cmpb #1 bne sprite_notgo_left dec ,x jmp sprites_mechanics_done sprite_notgo_left: cmpb #2 bne sprite_notgo_right inc ,x jmp sprites_mechanics_done sprite_notgo_right: ; 2x-movement cmpb #11 bne sprite_notgo_left2x dec ,x dec ,x jmp sprites_mechanics_done sprite_notgo_left2x: cmpb #12 bne sprite_notgo_right2x inc ,x inc ,x jmp sprites_mechanics_done sprite_notgo_right2x: ; 3x-movement cmpb #21 bne sprite_notgo_left2xx dec ,x dec ,x dec ,x jmp sprites_mechanics_done sprite_notgo_left2xx: cmpb #22 bne sprite_notgo_right2xx inc ,x inc ,x inc ,x jmp sprites_mechanics_done sprite_notgo_right2xx: sprites_mechanics_done: puls y puls x lda ,x++ lda ,y+ dec sprites_for_var bne sprites_mechanics ; show sprites 4 for menu lda state cmpa #0 bne no_menu_sprites lda #3 sta spritesnr no_menu_sprites ;*************************************************************************** ; INGAME: INGAME MECHANICS ;*************************************************************************** ; collisions mechanics only ingame lda state cmpa #2 lbne mechanics_done ; level management ; add counter for ;*************************************************************************** ; INGAME: LEVELUP? WAIT ;*************************************************************************** ; counter_ms inc counter_ms lda counter_ms cmpa #120 blt no_counter_activity lda #-75 sta counter_ms ; counter_sec inc counter_sec lda counter_sec cmpa #4 blt no_counter_activity lda #0 sta counter_sec ; counter_min ; inc counter_min ; lda counter_min ; cmpa #120 ; blt no_counter_activity ; level inc level ; show level ; no bigger than 7 lda level cmpa #7 blt no_counter_activity_less lda #7 sta level jmp no_counter_activity no_counter_activity_less ; play music (set flag to wait for music) lda #1 ; one means, we are about to sta Vec_Music_Flag ; store it in appropriate RAM lda #6 sta soundeffect no_counter_activity: ; levels and sprite nr lda #5 sta spritesnr ; level 2 lda level cmpa #1 blt no_level1 lda #6 sta spritesnr no_level1: ; level 2 lda level cmpa #2 blt no_level2 lda #7 sta spritesnr no_level2: ; level 3 lda level cmpa #3 blt no_level3 lda #8 sta spritesnr no_level3: ; level 4 lda level cmpa #4 blt no_level4 lda #9 sta spritesnr no_level4: ; level 5 lda level cmpa #5 blt no_level5 lda #10 sta spritesnr no_level5: ; level 6 lda level cmpa #6 blt no_level6 lda #12 sta spritesnr no_level6: ;*************************************************************************** ; INGAME: SIMPLE COLLISIONS ;*************************************************************************** ; no_mechanics_done ; problem bra only local big jmp ;jmp mechanics_done ;no_mechanics_done: ; collisions (box collision - handmade) ; Box-Collision ; <-- AY ; [e]--- ; | P | <-- BY ; --[e] ; ^ AX ^ BX ; lda spritesnr deca ; -- first is not counted! sta sprites_for_var ldx #spritesyx ldy #spritestype ; go over player (=sprite 0) ++1 lda ,x++ lda ,y+ sprites_collisions: ; check them all! pshs x pshs y ; Y AY<>BY ; AY lda spritesyx adda #15 cmpa ,x blt spriteysmallerorbigger ; BY lda spritesyx suba #15 cmpa ,x bgt spriteysmallerorbigger ; X:AX<>BX ; AX lda ,x+ lda spritesyx+1 adda #15 cmpa ,x blt spriteysmallerorbigger ; BX lda spritesyx+1 suba #15 cmpa ,x bgt spriteysmallerorbigger ;ldu #string_sprite_bigger ;jsr Print_Str_yx puls y puls x pshs x pshs y ; game over? lda ,y cmpa #2 bne no_colenemy lda #3 sta state ; play music (set flag to wait for music) lda #1 ; one means, we are about to sta Vec_Music_Flag ; store it in appropriate RAM lda #4 sta soundeffect jmp spriteysmallerorbigger no_colenemy: ; bonbon lda ,y cmpa #1 bne no_bonbon lda score inc score ; sound lda #1 ; one means, we are about to sta Vec_Music_Flag ; store it in appropriate RAM lda #5 sta soundeffect ; change position! lda ,x adda #144 suba spritesyx+1 sta ,x lda ,x+ suba #161 ; adda spritesyx sta ,x no_bonbon: spriteysmallerorbigger puls y puls x lda ,x++ lda ,y+ dec sprites_for_var bne sprites_collisions mechanics_done: ;*************************************************************************** ; INGAME: DEBUG SPRITES AS POINTS ;*************************************************************************** ; debug display sprite points jmp sprites_for_debug_done ; intensity jsr Intensity_5F ; show all dots here! ; for (i=4;i>=0;i--) lda spritesnr lda #12 sta sprites_for_var ;variable with a value of 5 ldx #spritesyx sprites_for_debug: ;This is the label at the start of the loop ; lda ,x ;These are the instructions we want to repeat 5 times ; inca ; sta ,x ;These are the instructions we want to repeat 5 times pshs X ; store x lda #0 ; load A with 6, dots - 1 sta Vec_Misc_Count ; set it as counter for dots jsr Dot_List ; Plot a series of dots ; attention Dot_List is changing flags and register!!! puls x ; restore x ; add 2 bytes for yx!! lda ,x++ ; = ; lda sprites_for_var,x dec sprites_for_var ;Subtract the loop_variable by 1 bne sprites_for_debug ;If the loop variable is not Zero, jump to loop_start sprites_for_debug_done: ;*************************************************************************** ; DEBUG: RECTANGLE TEST (2 RECT AT TWO DIFFERENT POINTS) ;*************************************************************************** ; debug test rectangle jmp debug_rect jsr Intensity_5F lda #110 ldb #0 jsr Moveto_d ldx #grafix_quad jsr Draw_VLc jsr Reset0Ref ; reset to 0,0 ; move to 0 0 ;lda #-110 ; to 0 (y) ;ldb #0 ; to 0 (x) ;jsr Moveto_d ; move the vector beam the jsr Delay_3 jsr Intensity_5F lda #10 ldb #10 jsr Moveto_d ldx #grafix_quad jsr Draw_VLc jsr Reset0Ref ; reset to 0,0 debug_rect: ;*************************************************************************** ; INGAME: MENU PATCH 2 SPRITES + - ;*************************************************************************** ; patch two sprites for menu lda state ; menu cmpa #0 bne no_sprite_help_position_patch lda #8 sta spritesyx+2 sta spritesyx+4 lda #-30 sta spritesyx+3 lda #25 sta spritesyx+5 no_sprite_help_position_patch: ;*************************************************************************** ; INGAME: MOVE AWAY THE NOT USED SPRITES ;*************************************************************************** ; move away not used sprites ; otherwise: problem with collision if they are coming in! ; MAX: 12 - ; movement lda #12 ; lda spritesnr sta sprites_for_var ldx #spritesyx ldy #spritesmove ldb #0 sprites_mechanics_moveaway: pshs x pshs y cmpb spritesnr blt not_affected_sprite_moveaway ; y-movement lda #120 sta ,x ; x-movement lda ,x+ lda #120 sta ,x not_affected_sprite_moveaway: puls y puls x lda ,x++ lda ,y+ incb ; b++ dec sprites_for_var bne sprites_mechanics_moveaway ;*************************************************************************** ; INGAME: DISPLAY SPRITES ;*************************************************************************** ; display sprites ; don't do it ; jmp sprites_for_display_no ; for (i=4;i>=0;i--) lda spritesnr sta sprites_for_var ; specials for ingame! ; ldb state ; ldx #spritesyx ; cmpb #1 ; bne not_sprites_ingame_change ; deca ; sta sprites_for_var ; ldb ,x++ ;not_sprites_ingame_change: ldx #spritesyx ldy #spritestype ; for sprites_for_display: ; for pshs x pshs y ; move the pen lda ,x+ ldb ,x+ jsr Moveto_d ; define the visuals lda ,y+ sta sprites_tmp_type ; types ... ; jsr Intensity_5F ldx #grafix_quad ; default grafixs cmpa #0 bne sprite_white ldx #grafix_quad_player ; default grafixs jsr Intensity_5F ; show only in ingame lda state cmpa #2 bne sprite_next sprite_white: cmpa #1 bne sprite_grey ldx #grafix_quad_bonbon ; default grafixs jsr Intensity_5F sprite_grey: cmpa #2 bne sprite_light jsr Intensity_7F sprite_light: jsr Draw_VLc sprite_next: jsr Reset0Ref ; reset to 0,0 puls y puls x lda ,x++ lda ,y+ dec sprites_for_var bne sprites_for_display ; reset jsr Intensity_5F sprites_for_display_no: ;*************************************************************************** ; MENU/GAMEOVER: DISPLAY TEXT ;*************************************************************************** ; display texts: title, ingame comments lda state ; menu cmpa #0 bne state_menu ; state ... jsr Intensity_7F ldu #string_title jsr Print_Str_yx ; play ldu #string_menu_play jsr Print_Str_yx ; code ldu #string_menu_code jsr Print_Str_yx ; credits ldu #string_menu_credits jsr Print_Str_yx ; info ; ldu #string_menu_info ; jsr Print_Str_yx bra state_done state_menu: ; intro cmpa #1 bne state_intro ; state ... jsr Intensity_7F ldu #string_explanation jsr Print_Str_yx ldu #string_explanation_ext jsr Print_Str_yx bra state_done state_intro: ; ingame cmpa #2 bne state_ingame ; ldu #string_ingame ; jsr Print_Str_yx bra state_done state_ingame: ; gameover cmpa #3 bne state_intro ; state ... jsr Intensity_7F ldu #string_gameover jsr Print_Str_yx bra state_done state_gameover: state_done: ;*************************************************************************** ; INGAME/MENU: DISPLAY SCORE AND HIGHSCORE ;*************************************************************************** jsr Intensity_7F ; actual scores ; sorry dirty as hell! no chance for coder heaven .-) ; new highscore? lda score cmpa highscore blt no_new_highscore sta highscore no_new_highscore: ; scores lda #3 sta sprites_for_var scores_display: ; clear string lda #48 sta str_score+2 sta str_score+3 sta str_score+4 ; score lda sprites_for_var cmpa #1 bne not_score_actual ; score lda #0 sta str_score+1 lda score jmp no_score_display not_score_actual: ; highscore lda #50 sta str_score+1 lda highscore ; debug ; lda counter_sec ; lda level no_score_display: ; display score ; 100 cmpa #100 blt biggerthan100 suba #100 ; 1xx ldb #1 ; max 100 addb #48 ; 0 stb str_score+2 biggerthan100: ; 00,10,20,30,40,50,60,70,80 ; 90 cmpa #90 blt biggerthan90 suba #90 ; .9x ldb #9 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan90: ; 80 cmpa #80 blt biggerthan80 suba #80 ; .9x ldb #8 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan80: ; 70 cmpa #70 blt biggerthan70 suba #70 ; .9x ldb #7 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan70: ; 60 cmpa #60 blt biggerthan60 suba #60 ; .9x ldb #6 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan60: ; 50 cmpa #50 blt biggerthan50 suba #50 ; .9x ldb #5 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan50: ; 40 cmpa #40 blt biggerthan40 suba #40 ; .9x ldb #4 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan40: ; 30 cmpa #30 blt biggerthan30 suba #30 ; .9x ldb #3 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan30: ; 20 cmpa #20 blt biggerthan20 suba #20 ; .9x ldb #2 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan20: ; 10 cmpa #10 blt biggerthan10 suba #10 ; .9x ldb #1 ; addb #48 ; 0 stb str_score+3 jmp under10 biggerthan10: under10: adda #48 ; 0 sta str_score+4 ; show score ldu #str_score jsr Print_Str_yx ; / score dec sprites_for_var bne scores_display ; show title not menu lda state cmpa #0 beq not_menu_state ; title ;ldu #string_title_short ;jsr Print_Str_yx not_menu_state ;*************************************************************************** ; INGAME: SPRITES MOVE OVER THE EDGES ;*************************************************************************** ; over the edge > change directions etc! ; management / gamemechnics / update ... ; movement lda spritesnr sta sprites_for_var ldx #spritesyx ldy #spritesmove sprites_mechanics_overedge: pshs x pshs y ldb ,y ; y-movement ; 3+13 cmpb #23 beq sprite_notgo_up_oved_13 cmpb #13 beq sprite_notgo_up_oved_13 cmpb #3 bne sprite_notgo_up_oved sprite_notgo_up_oved_13 ; dec ,x ldb ,x cmpb #-127 bgt sprite_notgo_up_oved_no ldb ,x+ ldb ,x addb #53 ; addb spritesyx stb ,x sprite_notgo_up_oved_no jmp sprites_mechanics_done_overedge sprite_notgo_up_oved: ; 4+14 ldb ,y cmpb #24 beq sprite_notgo_down_oved_14 cmpb #14 beq sprite_notgo_down_oved_14 cmpb #4 bne sprite_notgo_down_oved sprite_notgo_down_oved_14 ; dec ,x ldb ,x cmpb #126 blt sprite_notgo_down_oved_no ldb ,x+ ldb ,x subb #67 ;subb spritesyx+1 stb ,x ; sprite 1: special sprite aims!! ; lda sprites_for_var ; cmpa #2 ; bne not_sprite_1 ; lda spritestype+1 ; stb ,x ;not_sprite_1 sprite_notgo_down_oved_no jmp sprites_mechanics_done_overedge sprite_notgo_down_oved: ; x-movement ldb ,x+ ; 1+11 ldb ,y cmpb #21 beq sprite_notgo_left_oved_11 cmpb #11 beq sprite_notgo_left_oved_11 cmpb #1 bne sprite_notgo_left_oved sprite_notgo_left_oved_11 ; dec ,x ldb ,x cmpb #127 blt sprite_notgo_left_oved_no ; bring back the old data - dirty puls y puls x pshs x pshs y ldb ,x subb #-47 ; subb spritesyx+1 stb ,x sprite_notgo_left_oved_no jmp sprites_mechanics_done_overedge sprite_notgo_left_oved: ; 2+12 cmpb #22 beq sprite_notgo_right_oved_12 cmpb #12 beq sprite_notgo_right_oved_12 cmpb #2 bne sprite_notgo_right_oved sprite_notgo_right_oved_12 ; dec ,x ldb ,x cmpb #-127 bgt sprite_notgo_right_oved_no ; bring back the old data - dirty puls y puls x pshs x pshs y ldb ,x addb #87 subb spritesyx+1 stb ,x sprite_notgo_right_oved_no jmp sprites_mechanics_done_overedge sprite_notgo_right_oved: sprites_mechanics_done_overedge: puls y puls x lda ,x++ lda ,y+ dec sprites_for_var bne sprites_mechanics_overedge ;*************************************************************************** ; UPDATE SOUND ;*************************************************************************** ; music - do the sound jsr Do_Sound ; ROM function that does the ;*************************************************************************** ; LOOP ;*************************************************************************** ; gameloop lbra main ; and repeat forever ;*************************************************************************** ; END OF MAIN ;*************************************************************************** ;*************************************************************************** ; DATA SECTION EP ROM!!! READ ONLY!!! ;*************************************************************************** ;*************************************************************************** ; DATA SECTION (EPROM): GRAPHICS ;*************************************************************************** ; graphics rect_size equ 7 grafix_quad: ; logo vw 10 db 3 db 2*rect_size,0*rect_size db 0*rect_size,2*rect_size db -2*rect_size,0*rect_size db 0*rect_size,-2*rect_size grafix_quad_player: ; logo vw 10 db 5 db 2*rect_size,0*rect_size db 0*rect_size,2*rect_size db -2*rect_size,0*rect_size db 0*rect_size,-2*rect_size db 0*rect_size,1*rect_size db 2*rect_size,0*rect_size grafix_quad_bonbon: db 5 db 2*rect_size,0*rect_size db 0*rect_size,2*rect_size db -2*rect_size,0*rect_size db 0*rect_size,-2*rect_size db 0*rect_size,1*rect_size db 1*rect_size,0*rect_size ;*************************************************************************** ; DATA SECTION (EPROM): TEXTS ;*************************************************************************** ; texts ; string title (-115) string_title: DB 60,-125,"ooo SQUAREZ 2o15 ooo ", $80 string_menu_play: DB 20,-125,"COLLECT o AVOID ", $80 string_menu_info: DB 0,-60,"INFO", $80 string_menu_code: DB -80,-125,"DoMAKE CODE LA1N.CH", $80 string_menu_credits: DB -100,-125,"THKT RICHARD MoCARDS", $80 ; string explanation string_explanation: DB 10,-115,"COLLECT THE GREYS", $80 string_explanation_ext: DB -10,-115,"AVOID THE WHITES", $80 string_ingame: DB -10,-115,"SQUAREZ", $80 string_gameover: DB 0,-65,"GAME OVER", $80 string_title_short: DB 120,-120,"oooSQUAREZ", $80 ; debug ; debug joystick string_joystick_left: DB -60,-115,"CONTROL: LEFT", $80 string_joystick_right: DB -70,-115,"CONTROL: RIGHT", $80 string_sprite_bigger: DB -70,-115,"COLLISION: HERE", $80 ;*************************************************************************** ; DATA SECTION (EPROM): SOUNDs ;*************************************************************************** ; http://www.playvectrex.com/designit/chrissalo/soundplaying.htm music_bonbon: ; instrument & ; fdb $FEE8, $FEB6 ; ADSR and twang address tables, in Vectrex ROM fdb $FEEE, $FEB6 ; ADSR and twang address tables, in Vectrex ROM fcb 2,6 fcb 0,12 ;;;;;;;; fcb 19, $80 ; $80 is end marker for music music_levelup: ; instrument & ; fdb $FEE8, $FEB6 ; ADSR and twang address tables, in Vectrex ROM fdb $FEEE, $FEB6 ; ADSR and twang address tables, in Vectrex ROM fcb 2,20 fcb 0,12 ;;;;;;;; fcb 2,20 fcb 19, $80 ; $80 is end marker for music ;*************************************************************************** ; HINTS: Integrated collision detection ;*************************************************************************** ; COLLTEST equ $f8ff ; Collision detection ; ldx player1y ; Y/X Coordinates of object 1 ; ldy target1y ; Y/X Coordinates of object 2 ; As far I understand, these load ; both Y and X coordinates, because ; they are stored one after the other ; in the memory. ; lda #40 ; (Height of object #1 + Height of object #2)/2 ; ldb #30 ; (Width of object #1 + Width of object #2)/2 ; Thanks to Alex H. ; jsr COLLTEST ; Check for collision ; bcc alldone ; Branch to 'alldone' if no collision ; ; bcs would branch if collision