Videopac G7000 BIOS
Last changed: 2003-07-22

Summary of the BIOS routines

bank0: 0387h

Switches banks to bank 0, continues at 0408h in new bank.

InputNone
OutputNone
AltersP1
First usedChapter about bank-switching

bank01: 0383h

Switches banks from bank 2 to bank 0, bank 3 to bank 1, continues at 0408h in new bank.

InputNone
OutputNone
AltersP1
First usedChapter about bank-switching

bank02: 037Fh

Switches banks from bank 1 to bank 0, bank 3 to bank 2, continues at 0408h in new bank.

InputNone
OutputNone
AltersP1
First usedChapter about bank-switching

bank3: 038Bh

Switches banks to bank 3, continues at 0408h in new bank.

InputNone
OutputNone
AltersP1
First usedChapter about bank-switching

bitclear: 0280h (G7000 only)

Clears a bit in a VDC or external RAM bit field.

This routine is not available on the Videopac+ G7400.

InputA=bit number
 R1=pointer to end of bit field
OutputA=old bit
 R1=pointer to byte containing bit
 R2=bit mask
AltersNone
First usedChapter about bit fields

bitset: 028Ah (G7000 only)

Sets a bit in a VDC or external RAM bit field.

This routine is not available on the Videopac+ G7400.

InputA=bit number
 R1=pointer to end of bit field
OutputA=old bit
 R1=pointer to byte containing bit
 R2=bit mask
AltersNone
First usedChapter about bit fields

bittest: 026Ah (G7000 only)

Tests, if a bit is set in VDC or external RAM bit field.

This routine is not available on the Videopac+ G7400.

InputA=bit number
 R1=pointer to end of bit field
OutputA=bit
 R1=pointer to byte containing bit
 R2=bit mask
AltersNone
First usedChapter about bit fields

calcchar23: 014Bh

Calculates which bytes to put into character control register offset 2 and 3.

InputR4=y
 R5=char
 R6=color
OutputR5/R6=byte 2/3
AltersA
First usedChapter about other useful routines

clearchar: 016Bh

Clears all characters.

InputNone
OutputNone
AltersA, R0, R2
First usedChapter about other useful routines

decodejoystick: 03B1h

Converts the delta x/y from getjoystick into a direction.

InputR2=delta x
 R3=delta y
OutputR1=direction: 0=right, 1=right+up, etc.
AltersA, R0
First usedChapter about other joystick

divide: 03CFh

Calculates R4=R2/R3, R5=R2%R3.

InputR2=dividend
 R3=divisor
OutputR4=R2/R3
 A=R5=R2%R3 (modulo operator, so R3*R4+R5=R2)
AltersR6
First usedChapter about other useful routines

doclock: 01B0h

Updates the clock display if necessary.

InputR4=y
 R6=color (both must be the same as in initclock)
OutputNone
AltersA, R0, R1, R2, R5, R6, P1, table
First usedChapter about clock routines

extramenable: 00ECh

Enables the external RAM, disables the VDC.

InputNone
OutputNone
AltersP1
First usedChapter about table routines

getjoystick: 038Fh

Gets the joystick position.

InputR1=which joystick to test
OutputR2=delta x
 R3=delta y
 F0=button
AltersA, R0, R1, P2
First usedChapter about other joystick

gfxoff: 011Ch

Turns the graphics off, so you can change the VDC registers.

InputNone
OutputNone
AltersA, interrupt enable
First usedChapter about "HELLO WORLD"

gfxon: 0127h

Turns the graphics on, you should not change VDC registers any more.

InputNone
OutputNone
AltersA, interrupt enable
First usedChapter about "HELLO WORLD"

init: 00F1h

Initialises VDC, internal and external RAM.

InputNone
OutputNone
AltersEverything
First usedChapter about other useful routines

initclock: 023Ah

Initialises quad0/1 to display a clock.

InputR3=x
 R4=y
 R6=color
OutputNone
AltersA, R0, R1, R5, R6
First usedChapter about clock routines

irq: 0009h

Begin of IRQ routine.

InputNone
Outputif VSYNC:RB0 active, VDC enabled
  R5=old A
  R6=old P1
  jmp 406h
 if not VSYNC:retr
AltersA, R0, P1 when VSYNC
First usedChapter about "HELLO WORLD"

irqend: 0014h

Restores the old state before the interrupt and does a retr.

InputRB0 active
 R5=old A
 R6=old P1
Outputretr
AltersA, P1
First usedChapter about interrupts

multiply: 03DDh

Multiplies R2 and R3.

InputR2=factor1
 R3=factor2
OutputA=R2*R3
AltersR2
First usedChapter about other useful routines

nibblemixer: 02A4h (G7000 only)

Mixes a nibble using a ROM table at 02B3h with selectable maximum.

This routine is not available on the Videopac+ G7400.

InputR5=nibble to mix
 R7=complement of maximum
OutputA=R3=new nibble<=CPL R7
AltersR5
First usedChapter about other useful routines

parsesnd: 04bh

Parse one sound opcode, part of sound irq handler.

InputR1=command byte
 R2=parameter byte
Outputretr or jmp 040Ah
First usedChapter about custom sound player

playsound: 01A2h

Tells the IRQ routines to start playing one of the built-in tunes.

InputA=pointer to tune in page 3
OutputNone
AltersA, interrupt enable
First usedChapter about sound

The built-in tunes

028htune_beep_errorAn error occurred
02Ehtune_explodeSomething explodes
03Chtune_alarmSomething went wrong
04Ahtune_selectTune from "SELECT GAME"
056htune_keyclickThe keyboard click
05Ahtune_buzzA short buzzing sound
05Ehtune_select2tune_select backwards
06Ahtune_shootA shot followed by an explosion

pluscmd: 0288h (G7400 only)

Send a command to the Videopac+ G7400.

InputR6=Parameter (A)
 R7=Command (B)
OutputNone
AltersA, R0, R1
First usedChapter about Videopac+ G7400

The command byte

000hplus_cmd_browSet the y position, set x position to 0
020hplus_cmd_loadySet the y position
040hplus_cmd_loadxSet the x position
060hplus_cmd_inccAdvance cursor position
080hplus_cmd_loadmSet read/write mode
0A0hplus_cmd_loadrSet the Videopac+ G7400 display mode
0C0hplus_cmd_loady0Choose which line is displayed as second line, useful for scrolling

The register M

000hplus_loadm_wrNormal write, advance cursor
020hplus_loadm_rdNormal read, advance cursor
040hplus_loadm_wrniWrite without moving cursor
060hplus_loadm_rdniRead without moving cursor
080hplus_loadm_wrslWrite slice, for redefining chars
0A0hplus_loadm_rdslRead slice, for redefining chars

plusdata: 028Ch (G7400 only)

Send data to the Videopac+ G7400.

InputR6=Parallel attributes
 R7=Character
OutputNone
AltersA, R0, R1
First usedChapter about Videopac+ G7400

The parallel attributes

080hcol_patr_blckEnable block gfx, set background color
040hcol_patr_invrtInvert the current char
020hcol_patr_dwdthDouble the width of the current char
010hcol_patr_dhghtDouble the height of the current char
008hcol_patr_stableDo not blink
000h-007hplus_col_colorForeground color

The serial attributes

080hcol_satr_enableEnable serial attributes
004hcol_satr_lineUnderline chars
002hcol_satr_boxDraw in boxed mode
001hcol_satr_concDraw concealed chars

plusenable: 02A1h (G7400 only)

Enables the Videopac+ G7400 graphics, disables the external RAM and VDC.

InputNone
OutputNone
AltersP1
First usedChapter about Videopac+ G7400

plushide: 0296h (G7400 only)

Hides all Videopac+ G7400 graphics.

InputNone
OutputNone
AltersA, R7
First usedChapter about Videopac+ G7400

plusloadr: 0283h (G7400 only)

Send the command plus_cmd_loadr to the Videopac+, handles 50/60Hz.

InputA=Parameter
OutputNone
AltersA, R0, R1, R6, R7
First usedChapter about Videopac+ G7400

The register R

080hplus_loadr_blnkEnable blink mode
040hplus_loadr_tt50 or 60 Hz, handled by BIOS
020hplus_loadr_tlMonitor mode, always 0 for VP+ G7400
010hplus_loadr_crsrShow cursor
008hplus_loadr_srowDisplay first line (called service row)
004hplus_loadr_concHide concealed chars
002hplus_loadr_boxEnable box mode
001hplus_loadr_dsplEnable display of other lines

plusmode: 0299h (G7400 only)

Sets the Videopac+ G7400 display parameters.

InputA=Luminance for Videopac+ colors
 R7=Transparency for VDC colors
OutputNone
AltersA
First usedChapter about Videopac+ G7400

plusready: 027Dh (G7400 only)

Polls the busy flag of the EF9340/41, waits until it is ready.

InputNone
OutputNone
AltersA, R0
First usedChapter about Videopac+ G7400

plusselectgame: 02C2h

Fills screen with "SELECT GAME", initialises VDC, internal and external RAM. Then waits until a key is pressed. This routine gives identical results to selectgame on non Videopac+ G7400 machines and can be used to detect the machine type.

InputNone
OutputVDC enabled, gfx on, A=key number
 G7000: jmp 040Ch in bank 3
 G7400: jmp 040Ch in bank 1
AltersEverything
First usedChapter about Videopac+ G7400

plusstart: 02ABh (G7400 only)

Initialises VDC and continues as if selectgame was called.

InputNone
OutputVDC enabled, gfx on, A=key number
 jmp 040Ch in bank 3
AltersEverything
First usedChapter about Videopac+ G7400

printchar: 03EAh

Prints a character or quad onto the screen.

InputR0=pointer to char/quad
 R3=x
 R4=y
 R5=char
 R6=color
OutputR0=pointer to next char/quad
 R3=next x
 R5/R6=byte 2/3
AltersA
First usedChapter about "HELLO WORLD"

putchar23: 0261h

Calculates which bytes to put into character data offset 2 and 3 and puts it into VDC.

InputR0=pointer to char/quad byte 2
 R4=y
 R5=char
 R6=color
OutputR0=pointer to next char/quad
 R5/R6=byte 2/3
AltersA
First usedChapter about other useful routines

random: 0293h (G7000 only)

Returns 2 random nibbles with selectable maximums using the T register.

This routine is not available on the Videopac+ G7400.

InputR2=compl. max. 1st nibble
 R7=compl. max. 2nd nibble
OutputA=R3=1st nibble<=CPL R2
 R2=2nd nibble<=CPL R7
AltersR4, R5, R7
First usedChapter about other useful routines

selectgame: 02C3h

Initialises VDC, internal and external RAM. Displays "SELECT GAME". Then waits until a key is pressed.

InputNone
OutputVDC enabled, gfx on
 A=key number
AltersEverything
First usedChapter about "HELLO WORLD"

soundirq: 0044h

Processes sound-events in IRQ.

InputOutput from vsyncirq
Outputretr or jmp 040Ah
AltersRestores everything stored in irq
First usedChapter about "HELLO WORLD"

tablebcdbyte: 017Ch

Displays a BCD byte via table, starts the table and activates it.

InputA=byte
 R1=pointer to char/quad
 R3=x
 R4=y
 R6=color
OutputR0=pointer to end of table
AltersA, R1, R2, R5, R6, P1
First usedChapter about other useful routines

tablebcdnibble: 0229h

Displays a BCD nibble via table.

InputA=nibble
 R0=pointer to table
OutputR0=pointer to end of table
AltersA, R5, R6
First usedChapter about other useful routines

tablechar23: 022Ch

Calculates which bytes to put into character data offset 2 and 3 and stores them into the table.

InputR0=pointer to table
 R4=y
 R5=char
 R6=color
OutputR0=pointer to end of table
 R5/R6=byte 2/3
AltersA
First usedChapter about other useful routines

tableend: 0132h

Puts an end marker into the table and activates it.

InputR0=pointer to table
OutputNone
AltersA, R0, P1
First usedChapter about table routines

tableprintchar: 0197h

Prints a character or quad onto the screen using the table, it's up to you to set the first bytes of the table.

InputR0=pointer to table
 R3=x
 R4=y
 R5=char
 R6=color
OutputR0=pointer to end of table
 R3=next x
 R5/R6=byte 2/3
AltersA
First usedChapter about table routines

tableput2: 0235h

Puts a 2 into the table.

InputR0=pointer to table
OutputR0=pointer to end of table
AltersA
First usedChapter about other useful routines

vdcenable: 00E7h

Enables the VDC, disables the external RAM.

InputNone
OutputNone
AltersP1
First usedChapter about table routines

vsyncirq: 001Ah

VSYNC routine: checks for collisions, counts the clock, copies the table, processes first part of sound event.

InputOutput from irq
Outputretr or jmp 40Ah when sound is playing
AltersA, R0, R1, F1
First usedChapter about "HELLO WORLD"

waitforkey: 013Dh

Waits until a key is pressed, plays the keyclick tune and returns which key was pressed.

InputNone
OutputA=key number
AltersP1, P2, F1, interrupt enable
First usedChapter about bit fields

waitvsync: 0176h

Waits until the next frame starts.

InputNone
OutputNone
AltersF1, interrupt enable
First usedChapter about other joystick

Resources used by the BIOS

Register Bank 0

R7The last key that was pressed
R6Stores P1 while in interrupt
R5Stores A while in interrupt
R4Pointer to the next sound event in page 3
R3Frames to wait for the next sound event
R2-R0Scratch

Internal RAM

8048 Processor
000h-007hRegister Bank 0
008h-017hStack
018h-01fhRegister Bank 1
BIOS
03Fh:71=Table copy active
03Fh:61=Sound active
03Fh:5-0unused
03Eh:71=Stop clock
03Eh:61=Count clock up
03Eh:5-0Frame counter (0-03Ch)
03DhCollision register

External RAM

07FhHow many registers to copy
07EhStart register
07Dh-XContents of registers
X-1How many registers to copy
......
02hClock: seconds
01hClock: minutes