; color.as - change screen colors from MSX-DOS(2) ; Copyright (C) 2001 ag0ny@ag0ny.com BDOS equ 00005h DEFDTA equ 00080h _STROUT equ 009h LF equ 00ah ; Line feed CR equ 00dh ; Carriage return ; RAM copy of VDP registers ; vdpregs0 -> R#0..R#7 ; vdpregs1 -> R#8..R#23 ; vdpregs0 equ 0f3dfh vdpregs1 equ 0ffe7h-8 ; VDP ports ; vdpport0 equ 098h ; VRAM read/write vdpport1 equ 099h ; VDP registers read/write vdpport2 equ 09ah ; Palette registers write vdpport3 equ 09bh ; Indirect register write ; vdp - send value in A to VDP register ; syntax: vdp reg# ; modifies: A ; note: **** INTERRUPTS MUST BE DISABLED **** ; vdp macro reg out (vdpport1),a ld a,reg or 080h out (vdpport1),a endm ; system - execute MSX-DOS(2) function ; system macro function ld c,function call BDOS endm ; ****************** ; ** Main program ** ; ****************** main: ld (STACK),sp ; print intro message ld de,MSG.INTRO system _STROUT call getopts ld a,(COLOR.FG) rlca rlca rlca rlca ld e,a ld a,(COLOR.BG) or e ld (vdpregs0+7),a vdp 7 ret error: system _STROUT ld sp,(STACK) ret getopts: ld hl,DEFDTA ld a,(hl) or a ret z ; default color change if no params inc hl ld a,(hl) ; because first character is the ; length of the commandline pointer go.1: cp ' ' jr nz,go.2 inc hl ; skip spaces at the beginning ld a,(hl) jr go.1 go.2: ; get first parameter or a ret z and 000001111b ld (COLOR.FG),a inc hl ld a,(hl) or a ret z cp ' ' jr z,go.3 and 000001111b ld e,a ld a,(COLOR.FG) ld d,a rlca ; x2 rlca ; x2 add a,d ; x5 rlca ; x10 add a,e ld (COLOR.FG),a go.3: inc hl ld a,(hl) cp ' ' jr nz,go.4 jr go.3 go.4: ; get second parameter and 000001111b ld (COLOR.BG),a inc hl ld a,(hl) or a ret z cp ' ' ret z ; more parameters ignored and 000001111b ld e,a ld a,(COLOR.BG) ld d,a rlca ; x2 rlca ; x2 add a,d ; x5 rlca ; x10 add a,e ld (COLOR.BG),a ret ; ********** ; ** Data ** ; ********** STACK: defs 2 COLOR.FG: defb 15 COLOR.BG: defb 4 MSG.INTRO: defb 'color.as - change screen colors from MSX-DOS(2)',CR,LF defb 'Copyright (C) 2001 ag0ny@ag0ny.com$' 1 ag0ny@ag0ny.com',CR,LF defb CR,LF,'$' MSG.USAGE: defb 'Usage: color ',CR,LF defb CR,LF defb ' Both and must be' defb ' a decimal',CR,LF defb ' number in the range 0..15',CR,LF,'$'