Skip to content

Instantly share code, notes, and snippets.

@fu-sen
Last active April 19, 2025 02:10
Show Gist options
  • Save fu-sen/c78393214ca3ded5e6c13cb44180b97f to your computer and use it in GitHub Desktop.
Save fu-sen/c78393214ca3ded5e6c13cb44180b97f to your computer and use it in GitHub Desktop.
/*
Balloons version 2 sprite 2 | MSX / z88dk
Copyright (c) 2025 BALLOON | FU-SEN
The MIT License (MIT) - https://mit.balloon.net.eu.org/#2025
zcc +msx -lndos -create-app -subtype=disk -bn ballo2-2 balloon2-2.c
--> BLOAD"BALLO2-2.MSX",R
zcc +msx -lndos -create-app -bn ballo2-2 balloon2-2.c
--> BLOAD"CAS:",R (BALLO2-2.CAS)
zcc +msx -lndos -create-app -subtype=wav -bn ballo2-2 balloon2-2.c
--> BLOAD"CAS:",R (BALLO2-2.WAV)
*/
void ldirvm(int addr, int vaddr, int size)
{
#asm
ld ix,0
add ix,sp
ld c,(ix+2) ; size
ld b,(ix+3)
ld e,(ix+4) ; vaddr
ld d,(ix+5)
ld l,(ix+6) ; addr
ld h,(ix+7)
call 005ch ; LDIRVM
#endasm
}
void chgclr(char forclr, char bakclr, char bdrclr)
{
#asm
ld ix,0
add ix,sp
ld a,(ix+2) ; BDRCLR
ld (0f3ebh),a
ld a,(ix+4) ; BAKCLR
ld (0f3eah),a
ld a,(ix+6) ; FORCLR
ld (0f3e9h),a
call 0062h ; CHGCLR
#endasm
}
void init32()
{
#asm
call 006fh ; INIT32
#endasm
}
void cls()
{
#asm
xor a ; Clear Z flag
call 00c3h ; CLS
#endasm
}
int gttrig(char btn)
{
#asm
ld a,l ; btn
call 00d8h ; GTTRIG
ld l,a
ld h,0
#endasm
}
void kilbuf()
{
#asm
call 00156h ; KILBUF
#endasm
}
void sprite_mode(char mode)
{
#asm
ld a,l
and 03h
ld hl,0f3e0h ; rg1sav
add a,(hl)
ld b,a
ld c,1 ; R#1
call 0047h ; WRTVDP
#endasm
}
int redclk(char addr)
{
#asm
ld c,l
ld ix,01F5h ; REDCLK
call 015fh ; EXTROM
and 0fh
ld l,a
ld h,0
#endasm
}
int peek(int addr)
{
#asm
ld a,(hl) ; addr
ld l,a
ld h,0
#endasm
}
unsigned int r;
unsigned char rnd()
{
r++;
r ^= r >> 3;
r ^= r << 5;
r ^= r >> 7;
return(r);
}
char balloon[32] = {
0x38,0x74,0xfa,0xfe,0xfe,0x7c,0x38,0x10,
0x10,0x08,0x08,0x10,0x10,0x08,0x08,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
int b=31,y[32];
char buf[128] = { 0 };
void main()
{
r=255;
chgclr(15, 1, 1);
init32();
sprite_mode(2);
cls();
ldirvm(balloon, 0x3800, 32);
while(!gttrig(0)){
if(r==255){
if(peek(0x2d)<1){
r=peek(0xfc9e);
}else{
r=redclk(2)*60+redclk(1)*10+redclk(0);
}
}
int x=rnd()%248;
buf[b*4+1]=x;
y[b]=224;
int c=rnd()%14+2;
/* buf[b*4+2]=0; */
buf[b*4+3]=c;
b+=31;
b%=32;
for(int l=0; l<8; l++) {
for(int c=0; c<32; c++) {
if(gttrig(0)){
break;
}
if(y[c]>0)
{
y[c]--;
}
if(y[c]<225){
buf[c*4]=(y[c]+239)%256;
}else{
buf[c*4]=209;
}
}
ldirvm(buf, 0x1b00, 128);
if(gttrig(0)){
break;
}
}
}
chgclr(15, 4, 7);
init32();
kilbuf();
}
@fu-sen
Copy link
Author

fu-sen commented Feb 21, 2025

balloon2-2_0001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment