Skip to content

Instantly share code, notes, and snippets.

@fu-sen
Last active February 12, 2021 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fu-sen/aa472e46843a349ccfbc6bde6fdfd86e to your computer and use it in GitHub Desktop.
Save fu-sen/aa472e46843a349ccfbc6bde6fdfd86e to your computer and use it in GitHub Desktop.
/*
MSX2+ YJK colors | MSX-BASIC 3.0+ / z88dk
Copyright (c) 2019 Keiichi Shiga (BALLOON | FU-SEN)
The MIT License (MIT) - https://mit.balloon.net.eu.org/#2019
zcc +msx -lndos -create-app -subtype=disk -bn yjkcolor yjkcolor.c
--> BLOAD"YJKCOLOR.MSX",R
*/
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
ld ix,0111h ; CHGCLR
call 015fh ; EXTROM
#endasm
}
void chgmdp(char mode)
{
#asm
ld a,l ; mode
ld ix,01b5h ; CHGMDP
call 015fh ; EXTROM
#endasm
}
void screen12()
{
#asm
ld hl,0fffah ; rg25sa
res 4,(hl)
set 3,(hl)
ld a,(hl)
ld b,a
ld c,25 ; R#25
call 0047h ; WRTVDP
#endasm
}
void nstwrt(int addr)
{
#asm
ld ix,0
add ix,sp
ld l,(ix+2) ; addr
ld h,(ix+3)
call 0171h ; NSTWRT
#endasm
}
void out(char reg, char data)
{
#asm
ld ix,0
add ix,sp
ld b,(ix+2) ; data
ld c,(ix+4) ; reg
out (c),b
#endasm
}
int gttrig(char num)
{
#asm
ld a,l ; num
call 00d8h ; GTTRIG
ld l,a
ld h,0
#endasm
}
void main()
{
int c=15;
chgmdp(8);
screen12();
chgclr(255, 0, 0);
c=c<<3;
nstwrt(0);
for (int y=0; y<212; y++) {
for (int x=0; x<256; x+=4) {
int j=x*64/256-32;
int k=y*64/212-32;
out(0x98, c|k&7);
out(0x98, c|k>>3&7);
out(0x98, c|j&7);
out(0x98, c|j>>3&7);
}
}
while (! gttrig(0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment