mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
balloon
This commit is contained in:
parent
0deadb694b
commit
bfe9f442e6
126
examples/balloonflight.p8
Normal file
126
examples/balloonflight.p8
Normal file
@ -0,0 +1,126 @@
|
||||
%import c64lib
|
||||
%import c64utils
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
ubyte perform_scroll = false
|
||||
|
||||
sub start() {
|
||||
c64.SPRPTR[0] = $0f00 / 64
|
||||
c64.SPENA = 1
|
||||
c64.SP0COL = 14
|
||||
c64.SPXY[0] = 80
|
||||
c64.SPXY[1] = 100
|
||||
|
||||
c64.SCROLX = c64.SCROLX & %11110111 ; 38 column mode
|
||||
|
||||
c64utils.set_rasterirq(1) ; enable animation
|
||||
|
||||
ubyte target_height = 10
|
||||
ubyte active_height = 24
|
||||
ubyte upwards = true
|
||||
|
||||
forever {
|
||||
ubyte mountain = 223 ; slope upwards
|
||||
if active_height < target_height {
|
||||
active_height++
|
||||
upwards = true
|
||||
} else if active_height > target_height {
|
||||
mountain = 233 ; slope downwards
|
||||
active_height--
|
||||
upwards = false
|
||||
} else {
|
||||
target_height = 8 + rnd() % 16
|
||||
if upwards
|
||||
mountain = 233
|
||||
else
|
||||
mountain = 223
|
||||
}
|
||||
|
||||
while not perform_scroll {
|
||||
; let the raster irq do its timing job
|
||||
}
|
||||
|
||||
perform_scroll = false
|
||||
c64scr.scroll_left_full(true)
|
||||
if c64.RASTER & 1
|
||||
c64.SPXY[1] ++
|
||||
else
|
||||
c64.SPXY[1] --
|
||||
|
||||
ubyte yy
|
||||
for yy in 0 to active_height-1 {
|
||||
c64scr.setcc(39, yy, 32, 2) ; clear top of screen
|
||||
}
|
||||
c64scr.setcc(39, active_height, mountain, 8) ; mountain edge
|
||||
for yy in active_height+1 to 24 {
|
||||
c64scr.setcc(39, yy, 160, 8) ; draw mountain
|
||||
}
|
||||
|
||||
yy = rnd()
|
||||
if yy > 100 {
|
||||
; draw a star
|
||||
c64scr.setcc(39, yy % (active_height-1), '.', rnd())
|
||||
}
|
||||
|
||||
if yy > 200 {
|
||||
; draw a tree
|
||||
ubyte tree = 30
|
||||
ubyte treecolor = 5
|
||||
if yy & %01000000 != 0
|
||||
tree = 88
|
||||
else if yy & %00100000 != 0
|
||||
tree = 65
|
||||
if rnd() > 130
|
||||
treecolor = 13
|
||||
c64scr.setcc(39, active_height, tree, treecolor)
|
||||
}
|
||||
|
||||
if yy > 235 {
|
||||
; draw a camel
|
||||
c64scr.setcc(39, active_height, 94, 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spritedata $0f00 {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
%option force_output ; make sure the data in this block appears in the resulting program
|
||||
|
||||
ubyte[] balloonsprite = [ %00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000 ]
|
||||
}
|
||||
|
||||
|
||||
irq {
|
||||
ubyte smoothx=7
|
||||
sub irq() {
|
||||
smoothx = (smoothx-1) & 7
|
||||
main.perform_scroll = smoothx==0
|
||||
c64.SCROLX = (c64.SCROLX & %11111000) | smoothx
|
||||
}
|
||||
}
|
||||
|
BIN
examples/compiled/balloonflight.prg
Normal file
BIN
examples/compiled/balloonflight.prg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -24,10 +24,9 @@ main {
|
||||
sub draw_lines() {
|
||||
ubyte i
|
||||
for i in 0 to 255 step 4 {
|
||||
; uword x1 = (320-256)/2 + sin8u(i)
|
||||
uword x1 = ((320-256)/2 as uword) + sin8u(i) ; TODO fix the need for a cast here
|
||||
uword x1 = ((320-256)/2 as uword) + sin8u(i)
|
||||
uword y1 = (200-128)/2 + cos8u(i)/2
|
||||
uword x2 = ((320-64)/2 as uword) + sin8u(i)/4 ; TODO fix the need for a cast here
|
||||
uword x2 = ((320-64)/2 as uword) + sin8u(i)/4
|
||||
uword y2 = (200-64)/2 + cos8u(i)/4
|
||||
graphics.line(x1, lsb(y1), x2, lsb(y2))
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
; clone of the old Scramble arcade game.
|
||||
; TODO work in progress...
|
||||
|
||||
%import c64lib
|
||||
%import c64utils
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
ubyte perform_scroll = false
|
||||
|
||||
sub start() {
|
||||
c64scr.plot(30,2)
|
||||
c64scr.print("skramble !")
|
||||
|
||||
c64.SCROLX = c64.SCROLX & %11110111 ; 38 column mode
|
||||
|
||||
c64utils.set_rasterirq(1) ; enable animation
|
||||
|
||||
ubyte target_height = 10
|
||||
ubyte active_height = 25
|
||||
|
||||
forever {
|
||||
if active_height < target_height {
|
||||
active_height++
|
||||
} else if active_height > target_height {
|
||||
active_height--
|
||||
} else {
|
||||
target_height = 8 + rnd() % 16
|
||||
continue
|
||||
}
|
||||
|
||||
while not perform_scroll {
|
||||
; let the raster irq do its timing job
|
||||
}
|
||||
perform_scroll = false
|
||||
c64scr.scroll_left_full(true)
|
||||
ubyte yy
|
||||
for yy in 0 to active_height-1 {
|
||||
c64scr.setcc(39, yy, 32, 2) ; clear top
|
||||
}
|
||||
for yy in active_height to 24 {
|
||||
c64scr.setcc(39, yy, 102, 8) ; draw mountain
|
||||
}
|
||||
|
||||
yy = rnd()
|
||||
if yy > 100 {
|
||||
; draw a star
|
||||
c64scr.setcc(39, yy % (active_height-1), '.', rnd())
|
||||
}
|
||||
|
||||
if yy > 200 {
|
||||
; draw a tree
|
||||
ubyte tree = 30
|
||||
ubyte treecolor = 5
|
||||
if yy & %01000000 != 0
|
||||
tree = 88
|
||||
else if yy & %00100000 != 0
|
||||
tree = 65
|
||||
if rnd() > 130
|
||||
treecolor = 13
|
||||
c64scr.setcc(39, active_height-1, tree, treecolor)
|
||||
}
|
||||
|
||||
if yy > 235 {
|
||||
; draw a camel
|
||||
c64scr.setcc(39, active_height-1, 94, 9)
|
||||
}
|
||||
|
||||
; check ship crash
|
||||
; ubyte shipchar3 = c64scr.getchr(2, 10)
|
||||
; if (shipchar3!=@'.' and shipchar3!=@' ') {
|
||||
; break ; game over
|
||||
; }
|
||||
|
||||
; draw space ship
|
||||
; c64scr.setcc(0, 10, @'*', 15)
|
||||
; c64scr.setcc(1, 10, @'=', 15)
|
||||
; c64scr.setcc(2, 10, @'>', 15)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
irq {
|
||||
ubyte smoothx=7
|
||||
sub irq() {
|
||||
smoothx = (smoothx-1) & 7
|
||||
main.perform_scroll = smoothx==0
|
||||
c64.SCROLX = (c64.SCROLX & %11111000) | smoothx
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
A=5
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user