galaxy: add galaxy demo

This commit is contained in:
Vince Weaver 2019-12-08 20:34:57 -05:00
parent 66734ee248
commit 1d581f8349
15 changed files with 812 additions and 0 deletions

BIN
galaxy/HELLO Normal file

Binary file not shown.

34
galaxy/Makefile Normal file
View File

@ -0,0 +1,34 @@
include ../Makefile.inc
DOS33 = ../dos33fs-utils/dos33
B2D = ../bmp2dhr/b2d
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
all: galaxy.dsk
galaxy.dsk: GALAXY_GR GALAXY_HGR HELLO
cp empty.dsk galaxy.dsk
$(DOS33) -y galaxy.dsk SAVE A HELLO
$(DOS33) -y galaxy.dsk SAVE A GALAXY_GR
$(DOS33) -y galaxy.dsk SAVE A GALAXY_HGR
########
GALAXY_GR: galaxy_gr.bas
../asoft_basic-utils/tokenize_asoft < galaxy_gr.bas > GALAXY_GR
########
GALAXY_HGR: galaxy_hgr.bas
../asoft_basic-utils/tokenize_asoft < galaxy_hgr.bas > GALAXY_HGR
####
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
clean:
rm -f *~ *.o *.lst *.inc GALAXY GALAXY_GR GALAXY_HGR

BIN
galaxy/empty.dsk Normal file

Binary file not shown.

BIN
galaxy/galaxy.dsk Normal file

Binary file not shown.

38
galaxy/galaxy2.bas Normal file
View File

@ -0,0 +1,38 @@
' cls()
10 GR
' ::_::
'for i=0,1600 do
20 FOR I=0 TO 400
'if(i<15)pal(i,({0,128,130,2,136,8,142,137,9,10,135,7})[i+1],1)
30 REM
'x=rnd(128)
40 X=RND(1)*128
'y=rnd(128)
50 Y=RND(1)*128
'a=atan2(x-64,y-64)+.17
'60 A=ATN(X-20,Y-20)+.17
60 IF X-64>0 THEN A=ATN(Y-64/X-64):GOTO 68
61 IF X-64=0 THEN A=1.57*SGN(Y-64):GOTO 68
62 A=ATN(X-64/Y-64)+3.14*SGN(Y-64)
68 A=A+1
'd=rnd(7)
70 D=RND(1)*7
'pset(x+cos(a)*d,y+sin(a)*d/3-cos(a)*d/4,max(0,pget(x,y)+.87-rnd()))
80 C=SCRN(X/3.3,Y/3.3)+0.87-RND(1)
81 IF C<0 THEN C=0
82 COLOR=C
85 XX=(X+COS(A)*D)/3.3
87 YY=(Y+SIN(A)*D/3-COS(A)*D/4)/3.3
88 IF XX<0 OR XX>39 GOTO 100
89 IF YY<0 OR YY>39 GOTO 100
90 PLOT XX,YY
'end
100 NEXT I
' circfill(64,64,5,11)
110 COLOR=15
115 PLOT 20,20:PLOT 19,20:PLOT 21,20
117 PLOT 19,19:PLOT 20,19:PLOT 21,19
119 PLOT 19,21:PLOT 20,21:PLOT 21,21
'120 INPUT A$
130 GOTO 20
'flip()goto _

48
galaxy/galaxy_cool.bas Normal file
View File

@ -0,0 +1,48 @@
' cls()
10 GR
' ::_::
'for i=0,1600 do
20 FOR I=0 TO 400
'if(i<15)pal(i,({0,128,130,2,136,8,142,137,9,10,135,7})[i+1],1)
30 REM
'x=rnd(128)
40 X=RND(1)*40:X=INT(RND(1)*3)+19
'y=rnd(128)
50 Y=RND(1)*40:Y=INT(RND(1)*3)+19
'a=atan2(x-64,y-64)+.17
'60 A=ATN(X-20,Y-20)+.17
60 IF X-20=0 AND Y-20=0 THEN GOTO 40
' X>0 case, plain ATN, Quadrants I and IV
64 IF X-20>0 THEN A=ATN((Y-20)/(X-20)):GOTO 68
' X=0 then pi/2 or -pi/2 depending on Y
65 IF X-20=0 THEN A=1.57*SGN(Y-20):GOTO 68
' X<0 and Y>=0, Quadrant II
67 IF Y-20>=0 THEN A=ATN((Y-20)/(X-20))+3.14:GOTO 68
' X<0 and Y<0 Quadrant III
67 A=ATN((Y-20)/(X-20))-3.14
68 A=A+1
'd=rnd(7)
70 D=RND(1)*7
'pset(x+cos(a)*d,y+sin(a)*d/3-cos(a)*d/4,max(0,pget(x,y)+.87-rnd()))
80 C=SCRN(X,Y)+0.87-RND(1)
81 IF C<0 THEN C=0
82 COLOR=C
85 XX=X+COS(A)*D
'87 YY=Y+SIN(A)*D/3-COS(A)*D/4
87 YY=Y+SIN(A)*D
88 IF XX<0 OR XX>39 GOTO 100
89 IF YY<0 OR YY>39 GOTO 100
90 PLOT XX,YY
'92 IF INT(C)=0 GOTO 100
'95 PRINT INT(X);" ";INT(Y);" ";INT(XX);" ";INT(YY);" A=";INT(A);" C=";INT(C)
'97 GET A$
'end
100 NEXT I
' circfill(64,64,5,11)
110 COLOR=15
115 PLOT 20,20:PLOT 19,20:PLOT 21,20
117 PLOT 19,19:PLOT 20,19:PLOT 21,19
119 PLOT 19,21:PLOT 20,21:PLOT 21,21
'120 INPUT A$
130 GOTO 20
'flip()goto _

48
galaxy/galaxy_gr.bas Normal file
View File

@ -0,0 +1,48 @@
' cls()
10 GR
' ::_::
'for i=0,1600 do
20 FOR I=0 TO 400
'if(i<15)pal(i,({0,128,130,2,136,8,142,137,9,10,135,7})[i+1],1)
30 REM
'x=rnd(128)
40 X=RND(1)*40
'y=rnd(128)
50 Y=RND(1)*40
'a=atan2(x-20,y-20)+.17
'60 A=ATN(X-20,Y-20)+.17
60 IF X-20=0 AND Y-20=0 THEN GOTO 40
' X>0 case, plain ATN, Quadrants I and IV
64 IF X-20>0 THEN A=ATN((Y-20)/(X-20)):GOTO 68
' X=0 then pi/2 or -pi/2 depending on Y
65 IF X-20=0 THEN A=1.57*SGN(Y-20):GOTO 68
' X<0 and Y>=0, Quadrant II
67 IF Y-20>=0 THEN A=ATN((Y-20)/(X-20))+3.14:GOTO 68
' X<0 and Y<0 Quadrant III
67 A=ATN((Y-20)/(X-20))-3.14
68 A=A+1
'd=rnd(7)
70 D=RND(1)*7
'pset(x+cos(a)*d,y+sin(a)*d/3-cos(a)*d/4,max(0,pget(x,y)+.87-rnd()))
80 C=SCRN(X,Y)+0.87-RND(1)
81 IF C<0 THEN C=0
82 COLOR=C
85 XX=(X+COS(A)*D/4)
87 YY=(Y+SIN(A)*D/12-COS(A)*D/16)
'87 YY=(Y+SIN(A)*D/3-COS(A)*D/4)
88 IF XX<0 OR XX>39 GOTO 100
89 IF YY<0 OR YY>39 GOTO 100
90 PLOT XX,YY
'92 IF INT(C)=0 GOTO 100
'95 PRINT INT(X);" ";INT(Y);" ";INT(XX);" ";INT(YY);" A=";INT(A);" C=";INT(C)
'97 GET A$
'end
100 NEXT I
' circfill(64,64,5,11)
110 COLOR=15
115 PLOT 20,20:PLOT 19,20:PLOT 21,20
117 PLOT 19,19:PLOT 20,19:PLOT 21,19
119 PLOT 19,21:PLOT 20,21:PLOT 21,21
'120 INPUT A$
130 GOTO 20
'flip()goto _

93
galaxy/galaxy_hgr.bas Normal file
View File

@ -0,0 +1,93 @@
' cls()
10 HGR
' ::_::
'for i=0,1600 do
20 FOR I=0 TO 1600
'if(i<15)pal(i,({0,128,130,2,136,8,142,137,9,10,135,7})[i+1],1)
30 REM
'x=rnd(128)
40 X=RND(1)*128
'y=rnd(128)
50 Y=RND(1)*128
'a=atan2(x-64,y-64)+.17
'60 A=ATN(X-20,Y-20)+.17
'60 IF Y-64>0 THEN A=ATN((X-64)/(Y-64)):GOTO 68
'61 IF Y-64=0 THEN A=1.57*SGN(X-64):GOTO 68
'62 A=ATN((X-64)/(Y-64))+3.14*SGN(X-64)
' PICO-8 uses TURNS instead of RADIANS so this is equivelant to roughly 1 radian
'68 A=A+1
60 IF X-64=0 AND Y-64=0 THEN GOTO 40
' X>0 case, plain ATN, Quadrants I and IV
64 IF X-64>0 THEN A=ATN((Y-64)/(X-64)):GOTO 68
' X=0 then pi/2 or -pi/2 depending on Y
65 IF X-64=0 THEN A=1.57*SGN(Y-64):GOTO 68
' X<0 and Y>=0, Quadrant II
67 IF Y-64>=0 THEN A=ATN((Y-64)/(X-64))+3.14:GOTO 68
' X<0 and Y<0 Quadrant III
67 A=ATN((Y-64)/(X-64))-3.14
68 A=A+1
'69 PRINT A
'd=rnd(7)
70 D=RND(1)*7
'pset(x+cos(a)*d,y+sin(a)*d/3-cos(a)*d/4,max(0,pget(x,y)+.87-rnd()))
' 1+.87-.99 = .88
' 1+.87-0.0 = 1.87
'80 C=SCRN(X/3.3,Y/3.3)+1.37-RND(1)
80 GOSUB 1100
81 C=C+0.87-RND(1)
82 IF C<0 THEN C=0
83 IF C>7 THEN C=7
84 HCOLOR=C
85 XX=(X+COS(A)*D)
87 YY=(Y+SIN(A)*D/3-COS(A)*D/4)
88 IF XX<0 OR XX>240 GOTO 100
89 IF YY<0 OR YY>192 GOTO 100
90 HPLOT XX,YY
'end
100 NEXT I
' circfill(64,64,5,11)
110 HCOLOR=7
115 HPLOT 61,60 TO 69,60:HPLOT 60,61 TO 70,61:HPLOT 60,62 TO 70,62
117 HPLOT 60,63 TO 70,63:HPLOT 60,64 TO 70,64:HPLOT 60,65 TO 70,65
119 HPLOT 60,66 TO 70,66:HPLOT 60,67 TO 70,67:HPLOT 61,68 TO 69,68
'125 INPUT A$
130 GOTO 20
'flip()goto _
1100 REM GET HCOLOR
1110 REM PARAMETERS: X Y
1120 REM RETURNS: C
1130 REM
1140 HP = 0:HX = X + 1:HY=Y
1150 ON (HX < 280) GOSUB 1300
1160 PR = HP:HP = 0:HX = HX - 2
1170 ON (HX > = 0) GOSUB 1300
1180 PL = HP:HX = HX + 1: GOSUB 1300
1190 ODD = HX - INT (HX / 2) * 2
1200 C = HH * 4
1210 IF NOT ((PL = PR) AND (PL < > HP)) THEN C = C + HP * 3: RETURN
1220 IF ODD THEN HP = NOT HP
1230 C = C + HP + 1
1240 RETURN
1250 REM
1260 REM GET PIXEL
1270 REM PARAMETERS: HX HY
1280 REM RETURNS: HH HP
1290 REM
1300 HH = INT (HX / 7)
1310 HV = INT (HY / 8)
1320 VO = PEEK (37)
1330 HO = PEEK (36)
1340 VTAB HV + 1: HTAB 1
1350 HA = PEEK (41) * 256
1360 HA = HA + PEEK (40) + HH
1370 VTAB VO + 1: HTAB HO + 1
1380 HA = HA + 8192 - 1024
1390 HP = PEEK (230) / 32
1400 IF HP = 2 THEN HA = HA + 8192
1410 HA = HA + (HY - HV * 8) * 1024
1420 HB = HX - HH * 7
1430 HV = PEEK (HA)
1440 HH = INT (HV / 128)
1450 HV = INT (HV / (2 ^ HB))
1460 HP = HV - INT (HV / 2) * 2
1470 RETURN

1
galaxy/hello.bas Normal file
View File

@ -0,0 +1 @@
10 PRINT "HELLO"

11
galaxy/test.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv) {
printf("%lf\n",atan2(1,1));
printf("%lf\n",atan2(1,-1));
printf("%lf\n",atan2(-1,1));
return 0;
}

495
ootw/ootw_c15.s Normal file
View File

@ -0,0 +1,495 @@
; Ootw for Apple II Lores
; Checkpoint-15 (it's the end of the game as we know it)
; by Vince "Deater" Weaver <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
ootw_c15:
; Initialize some variables
ootw_c15_restart:
jsr ootw_c15_level_init
;=========================
; c15_new_cave
;=========================
; enter new cave on level 15
c15_new_cave:
lda #0
sta GAME_OVER
jsr ootw_c15_level
c15_check_done:
lda GAME_OVER
cmp #$ff
beq quit_level
; only exit if done level
; FIXME: or quit pressed?
lda WHICH_JAIL
cmp #11
bne c15_new_cave
;===========================
; quit_level
;===========================
quit_level:
jsr TEXT
jsr HOME
lda KEYRESET ; clear strobe
lda #0
sta DRAW_PAGE
lda #<end_message
sta OUTL
lda #>end_message
sta OUTH
jsr move_and_print
jsr move_and_print
wait_loop:
lda KEYPRESS
bpl wait_loop
lda KEYRESET ; clear strobe
lda #0
sta GAME_OVER
jmp ootw_c15_restart
;=========================================
;=========================================
; Ootw Checkpoint 15 -- End of the game
;=========================================
;=========================================
; call once before entering for first time
ootw_c15_level_init:
lda #0
sta WHICH_ROOM
sta NUM_DOORS
lda #1
sta HAVE_GUN
sta DIRECTION ; right
lda #0
sta PHYSICIST_X
lda #10
sta PHYSICIST_Y
lda #P_STANDING
sta PHYSICIST_STATE
rts
;===========================
;===========================
; enter new room
;===========================
;===========================
ootw_c15_level:
;==============================
; each room init
;==============================
; setup per-room variables
lda WHICH_CAVE
bne room1
jsr init_shields
;===============================
; Room0 -- with the bathers
;===============================
room:
lda #(20+128)
sta LEFT_LIMIT
lda #(38+128)
sta RIGHT_LIMIT
; set right exit
lda #1
sta cer_smc+1
; set left exit
lda #0
sta cel_smc+1
lda #14
sta PHYSICIST_Y
; load background
lda #>(bath_rle)
sta GBASH
lda #<(bath_rle)
jmp room_setup_done
; ????
room1:
; cmp #1
; bne room2
; lda #(-4+128)
; sta LEFT_LIMIT
; lda #(39+128)
; sta RIGHT_LIMIT
; set right exit
; lda #2
; sta cer_smc+1
; set left exit
; lda #0
; sta cel_smc+1
; lda #8
; sta PHYSICIST_Y
; load background
; lda #>(hallway_rle)
; sta GBASH
; lda #<(hallway_rle)
jmp room_setup_done
room_setup_done:
sta GBASL
lda #$c ; load to page $c00
jsr load_rle_gr ; tail call
;=====================
; setup walk collision
jsr recalc_walk_collision
ootw_room_already_set:
;===========================
; Enable graphics
bit LORES
bit SET_GR
bit FULLGR
;===========================
; Setup pages (is this necessary?)
lda #0
sta DRAW_PAGE
lda #1
sta DISP_PAGE
;=================================
; setup vars
lda #0
sta GAIT
sta GAME_OVER
;============================
;============================
; Room Loop
;============================
;============================
room_loop:
;================================
; copy background to current page
jsr gr_copy_to_current
;==================================
; draw background action
lda WHICH_CAVE
bg_room0:
; cmp #0
; bne c4_no_bg_action
; lda FRAMEL
; and #$c
; lsr
; tay
; lda #11
; sta XPOS
; lda #24
; sta YPOS
; lda recharge_bg_progression,Y
; sta INL
; lda recharge_bg_progression+1,Y
; sta INH
; jsr put_sprite
c5_no_bg_action:
;===============================
; check keyboard
;===============================
jsr handle_keypress
;===============================
; move physicist
;===============================
jsr move_physicist
;===============================
; check room limits
;===============================
jsr check_screen_limit
;===============================
; adjust floor
;===============================
; lda PHYSICIST_STATE
; cmp #P_FALLING_DOWN
; beq check_floor0_done
; lda WHICH_CAVE
; cmp #0
; bne check_floor1
; lda #14
; sta PHYSICIST_Y
; lda PHYSICIST_X
; cmp #19
; bcc check_floor0_done
; lda #12
; sta PHYSICIST_Y
; lda PHYSICIST_X
; cmp #28
; bcc check_floor0_done
; lda #10
; sta PHYSICIST_Y
check_floor0_done:
check_floor1:
;=====================================
; draw physicist
;=====================================
jsr draw_physicist
;=====================================
; handle gun
;=====================================
jsr handle_gun
;=====================================
; draw foreground action
;=====================================
; lda WHICH_CAVE
; cmp #0
; bne c5_no_fg_action
c5_draw_rocks:
; lda #1
; sta XPOS
; lda #26
; sta YPOS
; lda #<small_rock
; sta INL
; lda #>small_rock
; sta INH
; jsr put_sprite
; lda #10
; sta XPOS
; lda #18
; sta YPOS
; lda #<medium_rock
; sta INL
; lda #>medium_rock
; sta INH
; jsr put_sprite
; lda #31
; sta XPOS
; lda #14
; sta YPOS
; lda #<large_rock
; sta INL
; lda #>large_rock
; sta INH
; jsr put_sprite
c5_no_fg_action:
;====================
; activate fg objects
;====================
;c2_fg_check_jail1:
; lda WHICH_JAIL
; cmp #1
; bne c2_fg_check_jail2
;
; lda CART_OUT
; bne c2_fg_check_jail2
;
; inc CART_OUT
;================
; move fg objects
;================
c4_move_fg_objects:
; lda CART_OUT
; cmp #1
; bne cart_not_out
; move cart
; lda FRAMEL
; and #$3
; bne cart_not_out
;
; inc CART_X
; lda CART_X
; cmp #39
; bne cart_not_out
; inc CART_OUT
;====================================
; page flip
;====================================
jsr page_flip
;====================================
; inc frame count
;====================================
inc FRAMEL
bne room_frame_no_oflo
inc FRAMEH
room_frame_no_oflo:
;==========================
; check if done this level
;==========================
lda GAME_OVER
beq still_in_room
cmp #$ff ; if $ff, we died
beq done_room
;===============================
; check if exited room to right
cmp #1
beq room_exit_left
;=================
; exit to right
room_right_yes_exit:
lda #0
sta PHYSICIST_X
cer_smc:
lda #$0 ; smc+1 = exit location
sta WHICH_ROOM
jmp done_room
;=====================
; exit to left
room_exit_left:
lda #37
sta PHYSICIST_X
cel_smc:
lda #0 ; smc+1
sta WHICH_ROOM
jmp done_room
; loop forever
still_in_room:
lda #0
sta GAME_OVER
jmp room_loop
done_room:
rts
end_message:
.byte 8,10,"PRESS RETURN TO CONTINUE",0
.byte 11,20,"ACCESS CODE: ANKD",0
.include "text_print.s"
.include "gr_pageflip.s"
.include "gr_unrle.s"
;.include "gr_fast_clear.s"
.include "gr_copy.s"
;.include "gr_copy_offset.s"
.include "gr_putsprite.s"
;.include "gr_putsprite_flipped.s"
.include "gr_putsprite_crop.s"
.include "gr_offsets.s"
;.include "gr_offsets_hl.s"
.include "gr_hlin.s"
.include "keyboard.s"
.include "physicist.s"
.include "alien.s"
.include "dummy_friend.s"
.include "gun.s"
.include "laser.s"
.include "alien_laser.s"
.include "blast.s"
.include "shield.s"
.include "door.s"
.include "collision.s"
; room backgrounds
.include "ootw_graphics/l15final/ootw_c15_final.inc"
; sprites
.include "ootw_graphics/sprites/physicist.inc"
.include "ootw_graphics/sprites/alien.inc"

43
xmas_2019/Makefile Normal file
View File

@ -0,0 +1,43 @@
include ../Makefile.inc
DOS33 = ../dos33fs-utils/dos33
B2D = ../bmp2dhr/b2d
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
all: xmas2019.dsk
xmas2019.dsk: SNOW
cp empty.dsk xmas2019.dsk
$(DOS33) -y xmas2019.dsk BSAVE -a 0x1000 SNOW
$(DOS33) -y xmas2019.dsk SAVE A HELLO.BAS
####
SNOW: snow.o
ld65 -o SNOW snow.o -C ../linker_scripts/apple2_1000.inc
snow.o: snow.s
#gr_copy.s random16.s fw.s hgr.s delay_a.s \
# vapor_lock.s gr_hline.s state_machine.s move_letters.s \
# background_final.inc
ca65 -o snow.o snow.s -l snow.lst
background_final.inc: background_final.png
$(PNG_TO_40x48D) asm background_final.png bg_final > background_final.inc
####
FIREWORKS.BAS: fireworks.bas
../asoft_basic-utils/tokenize_asoft < fireworks.bas > FIREWORKS.BAS
####
HELLO.BAS: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO.BAS
clean:
rm -f *~ *.o *.lst *.inc FIREWORKS.BAS

BIN
xmas_2019/empty.dsk Normal file

Binary file not shown.

1
xmas_2019/hello.bas Normal file
View File

@ -0,0 +1 @@
10 PRINT "HELLO"