Last active
April 19, 2025 02:10
-
-
Save fu-sen/c78393214ca3ded5e6c13cb44180b97f to your computer and use it in GitHub Desktop.
風船 Balloons version 2 sprite 2 | MSX-BASIC / z88dk https://msxjpn.jimdofree.com/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/%E9%A2%A8%E8%88%B9/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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(); | |
} |
Author
fu-sen
commented
Feb 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment