AdventureVision BIOS

ADVENTUREVISION [WIKI]

BIOS vector table

Vector Address Label Discription
00 000 RESET Start game cartridge
03 036 DISPLAY Display the current screen in VRAM
05 071 DRAW Draw sprite in VRAM with VRAM collision detection
07 0F0 DRAWP Draw sprite in VRAM with fixed point collision detection
09 1A0 DOSPRITES
0B 2B9 STEP Adjust sprites x-step and y-step properties and adjust X and Y displacements accordingly
0D 361 MOVEX Move sprite A pixels right(A>=0) or left(A<0)
0F 324 MOVEY Move sprite A pixels up(A>=0) or down (A<0)
11 2E2 CLRXRAM Fill bank 0 with 00 and banks 1-3 with FF
13 2EF CLS Fill VRAM (banks 1-3) with FF so all LEDs are off on display
15 02B CLRIRAM Fill internal CPU RAM 20-3F with 00
17 39A SCORE Add BCD number in A to BCD word at 33(MSB) and 34 (LSB)
19 3CE GAMEOVER displays screen in VRAM until button 3 is pressed and restarts game cartridge
1B 3A9 SOUND Write sound command
1D 2FF GETSPRITE Get Y shift, VRAM bank and VRAM pointer from sprite structure
1F 30E SETSPRITE Set Y shift, VRAM bank and VRAM pointer of sprite structure
21 31D SETSPRITEB Set Y shift, VRAM bank and VRAM pointer of sprite structure and (buggy) clear x and y steps
23 197 TEXT Uses fixed sprite structure to draw (text) graphics like Title, GameOver, Score
25 3F1 BITMASK Shift left 1 by R5 times and store result in A (A = 1 ^ R5)
27 3EF WREXP5 Write least significant nibble of A to expansion port 5
29 3ED WREXP4 Write least significant nibble of A to expansion port 4

BIOS functions

00 – RESET
Start game cartridge
Jump to $800 in the cartridge
Address: @000
Modified:
MB ⇒ 1
PC ⇒ @800

03 – DISPLAY
Display the current screen in VRAM
Wait for the sensor to trigger and render all content in XRAM bank 1 to 3 into the screen
Address: @036
Modified:
RB ⇒ 1
A ⇒ 0
P1 ⇒ 0
P2 ⇒ 0
R0 in RB0 ⇒ 0
R1 in RB0 ⇒ 4

05 – DRAW
Draw sprite in VRAM with VRAM collision detection
Address: @071
TODO

07 – DRAWP
Draw sprite in VRAM with fixed point collision detection
Address: @0F0
TODO

09 – DOSPRITES
TODO
Address: @1A0
TODO

0B – STEP
Adjust sprites x-step and y-step properties and adjust X and Y displacements accordingly
Case Sprite X-step:
> 0: ⇒ X-step = X-step-1, R2 = R2 + 1, A=$00
< 0: ⇒ X-step = X-step+1, R2 = R2 – 1, A=$00
Case Sprite Y-step:
> 0: ⇒ Y-step = Y-step-1, R3 = R3 + 1, A=$00
< 0: ⇒ Y-step = Y-step+1, R3 = R3 – 1, A=$00
Address: @2B9
Entry:
R1 ⇐ pointer to sprite structure [range: $00-$F8]
R2 ⇐ X displacement [range: $00-$FF]
R3 ⇐ Y displacement [range: $00-$FF]
Modified:
R1 ⇒ points to variable property of sprite structure
R2 ⇒ X displacement
R3 ⇒ Y displacement
A ⇒ $00 at least one of the displacements changed $FF: none of the displacements changed (X-step and Y-step where both 0)

0D – MOVEX
Move display position of sprite A pixels to the left or right.
When the new position is <0 or >149 it will wrap around. A variable at IRAM location 2E is read to determine the last VRAM bank.
This variable (IRAM[$2E]) must be initialized before using this function. It can be set to 3: for wrap at position >149 2: Wrap at position >99 or 1: wrap at position 49.
Address: @361
Entry:
A ⇐ X displacement [range: -1 to -128 move left, 0-127 move right]
R6 ⇐ sprite VRAM bank.
R7 ⇐ sprite VRAM pointer.
Modified:
R6 ⇒ new sprite VRAM bank.
R7 ⇒ new sprite VRAM pointer.
R0

0F – MOVEY
Move sprite A pixels up(A>=0) or down (A<0)
Add vertical displacement of A pixels to the Y coordinate pointed to by Y-shift, VRAM bank and VRAM pointer values.
When the new coordinate gets out of the range 0-39 it will wrap around to the next or previous column rather then the same column.
This effect can be be misused to move the coordinate in both the X and Y directions simultaneously.
IRAM location [$2E] Last VRAM page must be set to 3 prior to using this function for the wrapping mechanism to function correctly.
Address: @324
Entry:
A ⇐ Y displacement in pixels [range: 0 to 39 move up, -1 to -39 move down]
R5 ⇐ Y-shift
R6 ⇐ VRAM bank
R7 ⇐ VRAM pointer
IRAM [$2E] ⇒ Last VRAM bank [range: 1-3]
Modified:
R0 ⇒ $2E
R5 ⇒ new Y-shift
R6 ⇒ new VRAM bank
R7 ⇒ new VRAM
A

11 – CLRXRAM
Fill bank 0 with 00 and banks 1-3 with FF
Fill all XRAM bank 0 with $00 and banks 1 to 3 with $FF
Clears extra ram and turn off all LEDs in vram.
Address: @2E2
Modified:
A ⇒ 0
P1 ⇒ 0
R0 ⇒ 0
R3 ⇒ 0

13 – CLS
Fill VRAM (banks 1-3) with $FF so all LEDs are turned off on display
XRAM banks 1 to 3 are all filled with $FF Which turns off all the LEDs when VRAM is output to display.
Address: @2EF
Modified:
A ⇒ 0
P1 ⇒ 0
R0 ⇒ 0
R3 ⇒ 0

15 – CLRIRAM
Fill internal CPU RAM 20-3F with 00
Clear internal RAM from $20 to $3F for initialization
Address: @02B
Modified:
A ⇒ 0
R0 ⇒ 1F
R1 ⇒ 0

17 – SCORE
Add BCD number in A to BCD word
The BCD value in A is added to 16-bit BCD word stored at IRAM $33~$34. IRAM location $34 holds the LSB of the 16-bit word and IRAM location $33 the MSB of the 16-bit word. This function is used to increase the score.
Address: @39A
Entry:
A ⇐ BCD value [range: BCD($00-$99)]
Modified:
A ⇒ no overflow: least significant BCD digits (1s and 10s) else: most: significant BCD digits (100s and 1000s).
R0 ⇒ no overflow: $34 else $33
IRAM [$34] ⇒ BCD (IRAM [$34] + A)
IRAM [$33] ⇒ no overflow: no change else: BCD (IRAM [$33] + 1)

19 – GAMEOVER
This function draws a text sprite and keeps displaying VRAM until button 3 is pressed. After the button is pressed the cartridge is restarted.
The Y-shift, VRAM bank and VRAM pointer values in R5, R6 and R7 respectively are stored at the sprite structure at XRAM bank 0 addr $00. This sprite structures graphics pointer property is set to 0 and therefore the sprite graphic must be 256-byte aligned to be displayed correctly.
Address: @3CE
Entry:
R5 ⇐ Y-shift [range: 0-7]
R6 ⇐ VRAM bank [range: 1-3]
R7 ⇐ VRAM pointer [range: $6-$FF]
Modified:
MB ⇒ 1
PC ⇒ @800

1B – SOUND
Write sound command
Sends sound command in R1 to COP411 sound chip
Address: @3A9
Entry:
R1 ⇐ Sound command
Modified:
R0 ⇒ 1
R2 ⇒ 0
P1 ⇒ 0
P2 ⇒ 0
A ⇒ 0

1D – GETSPRITE
Get Y shift, VRAM bank and VRAM pointer from sprite structure
R1 points to a 8-byte aligned sprite structure and it’s Y-shift, VRAM bank,and VRAM pointer are read into R5,R6 and R7 respectively.
The pointer to the sprite structure may point to any of the sprite structures properties but usually it points to the graphics pointer property.
Note that before calling this function, XRAM bank must be set to 0
Address:@2FF
Entry:
R1 ⇐ pointer to sprite structure [range: $00-$F8]
Modified:
R1 ⇒ points to sprite structures VRAM pointer. [(R1 & $F8) + $04]
R5 ⇒ Sprite Y-shift
R6 ⇒ Sprite VRAM bank
R7,A ⇒ Sprite VRAM pointer
Carry ⇒ cleared

1F – SETSPRITE
Set Y shift, VRAM bank and VRAM pointer of sprite structure
Y-shift, VRAM bank and VRAM pointer values in R5,R6 and R7 respectively are stored at the 8-byte aligned sprite structure pointed to by R1.
The sprite structures pointer may point to any of the sprite structures properties but usually it points to the graphics pointer property.
Note that before calling this function, XRAM bank must be set to 0
Address: @30E
Entry:
R1 ⇐ pointer to sprite structure in XRAM bank 0 [range: $00-$F8]
R5 ⇐ Sprite Y-shift [range: 0-7]
R6 ⇐ Sprite VRAM bank [range: 1-3]
R7 ⇐ Sprite VRAM pointer [range: $00-$FF]
Modified:
R1 ⇒ points to sprite structures VRAM pointer. [(R1 & $F8) + $04]
A ⇒ R7 (Sprite VRAM pointer)
Carry ⇒ cleared

21 – SETSPRITEB
Set sprite and clear x-step and y-step properties (buggy)
This function calls SETSPRITE and was supposed to clear the sprites x-step and y-step properties. Unfortunately a INC R1 instruction was forgotten resulting in clearing the sprites VRAM pointer and X-step properties instead.
Address: @31D
Entry:
R1 ⇐ pointer to sprite structure in XRAM bank 0 [range: $00-$FF]
R5 ⇐ Sprite Y-shift [range: 0-7]
R6 ⇐ Sprite VRAM bank [range: 1-3]
R7 ⇐ Sprite VRAM pointer [range: $00-$FF]
Modified:
R1 ⇒ points to sprite structures X-step. [(R1 & $F8) + $05]
A ⇒ 0
Carry ⇒ cleared

23 – TEXT
This function sets sets R1 itself and writes R0 to the sprite structure at $E0. It calls @30E (1F) and @071 (05) itself
Address: @197
Entry:
R0 ⇐ Initial data pointer (as far as I care, index of sprite as used by @802)
R5 ⇐ Y-shift value [0-7]
R6 ⇐ RAM bank to start writing to (((5 * x + y // 8) & $0300) >> 8)
R7 ⇐ RAM pointer ((5 * x + y // 8 + bank – 1) & $ff)
Modified:
@$E1 ⇒ R0
See DRAW

25 – BITMASK
Shift left 1 by R5 times and store result in A
This function converts the Y-shift value to a bit mask which can be used to clear a pixel (ORing) or set a pixel (complementing then ANDing) with VRAM.
Address: @3F1
Entry:
R5 ⇐ Y-shift value [0-7]
Modified:
A ⇒ 1 << R5
R1 ⇒ 0

27 – WREXP5
Write to expansion port 5
Write low nibble in A to port 5 of the 8243 Port expander and clears high nibble of A.
This function is of no use for the Adventure Vision unless an external interface is connected to the expansion slot with a 8243 Port expander.
It is unknown if there ever existed such an interface at all.
Address @3EF
Entry:
PORT5 ⇐ A & $0F
Modified:
A ⇒ A & $0F

29 – WREXP4
Write to expansion port 4
Write low nibble in A to port 4 of the 8243 Port expander and clears high nibble of A.
This function is of no use for the Adventure Vision unless an external interface is connected to the expansion slot with a 8243 Port expander.
It is unknown if there ever existed such an interface at all.
Address @3ED
Entry:
PORT4 ⇐ A & $0F
Modified:
A ⇒ A & $0F