Daily Archive for April 7th, 2009

Inside BlackFOX 3

I’ll start describing the screens now. They are not exactly in order, because I’m looking at an ASM file right now, and they go backwards there for some reason, which is unknown to me.

Console information – nothing interesting here (besides the fact that it’s (C) Black Phoenix). It just reads compile date/time (mov FS:#32770,__date_day__; – special ZASM macro that gives you compile date/time) from ACPI, and from itself. Waits till you press B. Nothing special.

Fox facts – I ripped this text off http://ozfoxes.com because I did, those people are nice, and I’m evil for not including copyright in test releases (I am going to edit it and add the (C))

WireFI configuration – this screen shows you wireless devices which are around you. It detects them, and shows a list of channel numbers and device names.

Joystick test – just redirects joystick data to the GPU, which renders a cute circle moving around as you press keys.

Run game – (Okay, they don’t go exactly backwards) Run the cartridge check routine. Possibly runs a game. Unlikely if someone has plugged it out with physgun.

The cartridge check routine does the following:

  • Checks if CD drive is connected (NOT IMPLEMENTED YET)
  • Checks if a cartridge is present (first byte is non-zero)
  • Checks if loader is present (first byte must be 2, aka JMP)
  • Searches for a magic byte (4607832, HEXish for FOX)
  • Reads cartridge flags
  • Runs the code from catrdige or copies it into RAM and runs from there.
  • Restores VideoBIOS

VideoBIOS handles drawing all these, and it has some specific code for each screen. The screen selection is done by this code (it’s fairly obvious):

db 4,25,65515,776,14,25,65514,512,14,25,65533,0,
db 211,0,1,14,250008,32768,10,8,49,19,8,49,18,8,60,31,24,201,0,202
db 201,0,0,0,0,0,0,0,0,0,0,0,0,0,0,354,31,354,60
db 369,396,996,1488,1777,3187,3366,97,214,0,342,14

As you can see, 38432 85 101592 58 with the 2358 283 58 2.

Actually this is the code:

mov EBP,#32768;
add EBP,ScreenList;
max EBP,ScreenList; min EBP,ScreenList.End;
call #EBP;
dexit;

ScreenList:
  db _BIOS_NULL,_BIOS_CUSTOM,_BIOS_INIT,_BIOS_TERMINAL,_BIOS_ERROR;
  db _BIOS_MENU,_BIOS_CONFIG,_BIOS_HWCONFIG,_BIOS_HWTEST,_BIOS_INFO;
  db _BIOS_LOAD;
ScreenList.End:

As you can see, it just reads current screen number from memory address 32768 (should have been 63488! Fix this lazy bastard!).

_BIOS_LOAD is interesting, because it’s not used at the moment (supposed to be loading screen for CD loading), right now it draws an AJAX-like loading wheel:

There is fox_draw routine which draws the fox on background. It takes shade as input, and sends polygon data to GPU vertex buffer.

_BIOS_MENU uses some smoothing tricks to draw the the scrolling menu.
_BIOS_CONFIG is the WireFI configuration screen, it shows a list of devices (CPU sends list count, and device ID’s in list). It has some reduant code for showing a moving pointer (you could select devices before, for no reason…).

_BIOS_HWTEST is a joystick test, and it uses dcvxpipe 3 mode to convert controller coordinates (-1..1) directly to screen coordinates.

There is extra routine called BIOS_ControllerState which draws a spinny thingy in window corner if WireFI controller is still scanning for a controller (it’s used by some routines). I hope you don’t need a picture of it, because it looks like two partial circles spinning. It’s so exciting.