stefano wrote:getk() should just get the current key code or zero, without waiting for a keypress.
fgetc_cons() should wait (it is meant for the normal text typing, here a buffered keyboard wuold fit perfectly).
OK, getk() will use "SKEY?", and fgetc_cons() will use "KEY" then. When there will be a nightly build with these implementations?
stefano wrote:There's still few basic funtions which could be implemented, a minimal timer/clock
How is this supposed to be implemented? It seems to me that the periodic interruption ($0038) should be redirected to a interrupt-counting routine before doing its usual work. Or is there any other way?
stefano wrote:and the joystick() function will permit to run almost all the existing demos.
Is this right?
Code: Select all
; Game device library for the CCE MC-1000.
; Emerson Jos? Silveira da Costa - 2013-03-11.
;
; ---FUDLR Stick bit pattern (nc, nc, nc, fire, up, down, left, right)
;
XLIB joystick
.joystick
; __FASTCALL__ : joystick no. in HL.
; 1 = Player 1's joystick.
; 2 = Player 2's joystick.
ld a,l
cp 1
jr z,j_p1
cp 2
jr z,j_p2
jr j_nop
.j_p1
; Player 1's joystick.
ld b,@11111101 ; Keyboard line selector.
; Keyboard line data: --FRLDU-.
ld c,@00100000 ; Fire key position.
jr j_p
.j_p2
; Player 2's joystick.
ld b,@11111110 ; Keyboard line selector.
; Keyboard line data: ---RLDUF.
ld c,@00000001 ; Fire key position.
.j_p
di
ld a,14 ; Select AY-3-8910's IOA register.
out ($20),a
ld a,b ; Select keyboard line via IOA.
out ($60),a
ld a,15 ; Select AY-3-8910's IOB register.
out ($20),a
in a,($40) ; Get keyboard line data via IOB.
ei
cpl ; In original data bits 0 represent keypress. Invert.
ld b,a
; Transfer fire to bit 0.
or c ; Fire pressed?
jr z,j_nofire
set 0,b
jr j_reverse
.j_nofire
res 0,b
.j_reverse
; Register B now contains ---RLDUF.
; Transfer to A in reverse order: ---FUDLR.
xor a
rr b
rla
rr b
rla
rr b
rla
rr b
rla
rr b
rla
jr .j_done
.j_nop
xor a
.j_done
ld l,a
ld h,0
ret
stefano wrote:Sound is a parallel point, there are two ways to make an old computer play: by chip based sound generators or with a bit banging loop on a known output (like the ZX Spectrum speaker).. the code for this latter approach is ready made, it is just a matter of finding a bit and a port (or memory location) which will produce an audible click. On the TI calculators it has been achieved by making the IR port interfering with a long wave radio receiver.
A good low level API for the YM chipset is something to be designed, though some basic function exists for targets like the MSX or Sega Master System.
MC-1000 uses the same sound co-processor as MSX, using these I/O ports:
* $20 (REG): Selects AY-3-8910's register.
* $40 (RD): Reads AY-3-8910's register selected.
* $60 (WR): Writes to AY-3-8910's register selected.
So maybe it's not a hard job to adapt MSX's sound-related routines to MC-1000.
There's also a trick in AY-3-8910 where you can produce clicks, and then the ZX-style routines could work in MC-1000 (and MSX and so on) too. The trick consists in making a channel silent via the "mixer" register. The "silent" channel will have a level non-zero wave that can be shaped by changing the channel's volume (0~15). Alternating the channel volume from 0 to 15 and vice-versa within a loop, we can get the same effect as with ZX Spectrum speaker.
How could I help with any of these?