From SMS Power!

Development: SF - 7000 IPL

+Contents

Overview

The SF-7000 Initial Program Loader ROM uses all of the Z80's interrupt vectors to provide capabilities to software running on the device, when enabled.

They will usually be accessed using the rst and call instructions, with the exception of $00 which does not return, and thus is entered with a jp.

Downloads

SF-7000 Initial Program Loader ROM.zip

SF-7000 IPL disassembly.zip

Interrupt vector routines

$00 - Self test

This is the normal boot entry point. It performs self-test routines and then attempts to boot from disk.

The self-test routines are:

  1. Set all PSG channels to silence, repeatedly. Any PSG error will likely result in audio output, but this cannot be detected by the software.
  2. Test the stack. This is probably to rule out memory problems from the next tests. On error, it will lock up, while beeping: (beep) (beep) (pause) (repeat).
  3. Initialise the SC-3000 and SF-7000 PPI chips for normal operation, reset the floppy disk controller and turn off the disk drive.
  4. Read the VDP status twice - although this has no noticeable effect.
  5. Perform a checksum of the IPL ROM. The summation of all bytes, modulo 256, should be zero. On error, it will lock up, while beeping: (beep) (pause) (repeat).
  6. Turn off the screen and disable VDP interrupts.
  7. Write a value to every byte of VRAM, then read them back from the start. If the value read does not match what was written, lock up while beeping: (beep) (beep) (beep) (pause) (repeat).
  8. Perform the same test on RAM - first the upper 48KB, then the lower 16KB (normally mapped to the IPL ROM) by using RAM-resident code. On error, it will lock up, while beeping: (beep) (beep) (pause) (repeat).

If all self-test routines complete without error, it proceeds to boot normally.

$08 - Initialise disk/disk presence check

Parameters
none
Returns
carry set on error
Destroys
af

Turns on the disk controller, spins up the disk, checks that the disk is spinning fast enough (approximately 350RPM), and sets up the correct drive parameters in the FDC. A side effect is that the disk seeks to track 0, sector 1. This should be called before using other IPL ROM disk commands. It also serves as a disk presence check - the most likely reason for an error is because no disk is inserted.

$10 - Read disk sector

Parameters
de = destination buffer (256 bytes)
b = sector number (1..16)
c = track number (0..39)
Returns
carry set on error
Destroys
af

Reads a 256-byte sector from the disk to the specified address in RAM.

When the IPL ROM is active (as it must be to use this function), RAM addresses $0000..$3fff cannot be read, but they can be written, so there is no problem to load data to these addresses. Some software (eg. Disk Basic) will not work if this is not the case.

$18 - Write disk sector

Parameters
de = source buffer (256 bytes)
b = sector number (1..16)
c = track number (0..39)
Returns
carry set on error
Destroys
af

Writes a 256-byte sector from the specified address in RAM to the disk. It then pauses, and attempts to read it back. If there is no problem, it returns; otherwise, it will repeat the process up to 256 times before failing. The read back process does not attempt to verify that the data read matches what was written, probably because the low-level disk data checksums provide sufficient error-checking.

$20 - Format disk

Parameters
none
Returns
carry set on error
Destroys
af

Formats the entire disk and writes a blank directory and empty FAT.

$28 - SC-3000 utility program

This will start up a program that allows you to copy and format disks.

$30 - Warm boot

This bypasses the self-test routines (marks them as complete without performing them), and jumps straight to the booting process.

$38 - Do nothing

There is no functionality hooked up to this entry point; it will return (almost) immediately.

Boot process

The boot process does the following:

  1. Performs the self-test if it is not marked as passed
  2. Initialises the VDP with these data:
    RegisterValueInterpretation
    0%00000000No line ints, turn off features
    1%11010000Display enable, mode 1
    2%00000010Tilemap address $0800
    3$00Colour table address
    4$03Pattern generator address
    5$00Sprite table address
    6$00Sprite tile number modifier
    7$f1Backdrop color 1
  3. Loads the standard 6x8 pixel SC-3000 font into VRAM, and clears the tilemap and sprite table, and sets the colour table so the screen is black with white text
  4. Sets its console emulation cursor position to (2,0)
  5. Spins up the disk and reads track 0, sector 0 into RAM at $ff00
    1. If the start of the data read is "SYS:" (followed by the disk name), its name is displayed on-screen and execution goes to $ff20 (offset $20 in the disk image) where there must be a boot loader.
  1. If the start of the data read does not match this string, it shows a message to prompt the user to insert a suitable disk and restart.

Other useful routines

There are some other useful routines in the IPL ROM that do not have API-like entry points, but are useful and are used by some software. These routines will use memory in the $fc00-$fcff range so software using them must avoid that range. All functions listed below are known to be used by at least one disk program. The function names are unofficial.

$6e1 - ipl_write_text

Parameters
hl = pointer to text
Returns
Nothing
Destroys
Nothing

This routine will display the null-terminated string pointed to by hl to the screen using the IPL's console emulation routines. The string consists of ASCII text and control characters. The available control characters are:

ValueMeaning
$00End of string
$08Backspace (BS, \b)
$0aNew line (LF, \r)
$0cClear screen (FF, \f)

Apart from these control characters, the only other characters that can be displayed are those in the 7-bit ASCII range (values $20 to $7f), so the SC-3000 font's extended characters are unavailable. The only difference in the available characters are that $5c "\" is displayed as "¥" (yen symbol) and $5f "_" is displayed as "π" (lowercase greek letter pi).

$612 - ipl_read_key

Parameters
None
Returns
a = character set code for next non-modifer key to be pressed
Destroys
flags

This will wait for the user to press any key, apart from the modifying keys like Shift, Ctrl, cursors, etc, which are ignored. The effect of the Shift key is taken into account, so for example the returned value could be 'a' or 'A' depending on whether Shift was held while the A key was pressed.

$94a - ipl_beep_a_times

Parameters
a = number of times to beep
Returns
Nothing
Destroys
Nothing

Plays a 2kHz sound for 51ms, followed by silence for 51ms. This is repeated a times.


Retrieved from http://www.smspower.org/Development/SF-7000IPL
Page last modified on Mon Jul 18, 2011 3:17 pm