Rasterload

Found on:
"Cyforce 1"
"Fast"
"Game Over"
"I-Alien"
"Microsprose Soccer"
"Sceptre of Baghdad"
"World Cup Soccer Italia '90"

Loader files:
ROM Header
Contains turbo loader code
ROM Data
Autostart code

Encoding:
Endianess:MSbF
Threshold:0x0200
Lead-in:32 x 0x80
Sync:0xFF
Byte:8 bits
Phy 0-bit:Short
Log 0-bit:Short

Structure:
Header:Yes
Checksum:Yes
Header:
00-01 Load address (Low-High order)
02-03 Load end address (Low-High order) (Inclusive)

Checksum:
All data bytes are EOR:ed. First byte after data is the checksum cancellation byte.
The EOR:ed data bytes EOR:ed with this byte should result in a 0x00 value.

Trailer:
Data seems to always be followed by 7 '1' bits. Loader does not check for these.
.pc = $033c

.byte $03,$a7,$02,$04,$03
.text "CYFORCE 1"
.byte 0,0,0,0,0,0,0

C0351:pha
 tya
 pha
 lda$dc0d
 lda$dd05// Fetch timer high byte. Timer starts at 0x8200
 ldy#$19
 sty$dd0e
 asl// Shift Timer value. Any duration longer than 0x200 will give a '0' bit
 rol$fc// ROL = MSbF loader
 lda$d020
 eor#0
 sta$d020
 lda$fc
 eor#$ff// Invert loaded bits so short durations = '0' bit
C036e:jmp$0371// SMC

// Wait for lead-in %10000000
C0371:cmp#$80// Wait for lead-in, %10000000
 bneexitIRQ
 lda#$7c
 staC036e+1// Change jmp to $037c
 bneC03e6// Sets loaded byte to 0xFE and exits IRQ

// Accessed by SMC JMP after lead-in detected
// Look for sync, 0x80 x ? + 1 0xFF
C037c:bcsexitIRQ
 cmp#$80
 beqC03e6// Sets loaded byte to 0xFE and exits IRQ
 cmp#$ff
 beqC038d
 lda#$71
 staC036e+1// Change jmp to $0371, default value. Sync failed, restart
 bneexitIRQ
C038d:lda#$94
 staC036e+1// Change jmp to $0394
 bneC03e6// Sets loaded byte to 0xFE and exits IRQ

// Accessed by SMC JMP after sync found
// Fetch header, 4 bytes
C0394:bcsexitIRQ
C0396:sta$f7//SMC
 incC0396+1
 ldaC0396+1
 cmp#$fb
 bneC03e6
 lda#$f7// Restore SMC STA to default value
 staC0396+1
 lda#$ae
 staC036e+1// Change jmp to $03ae
 bneC03e6// Sets loaded byte to 0xFE and exits IRQ

// Accessed by SMC JMP after header has been fetched
// Load data
C03ae:bcsexitIRQ
 ldy#0
 dec$01// $01 set to #5 by autostart code, so this will switch out BASIC ROM
 sta($f7),y
 inc$01// Switch out BASIC ROM
 eor$02// Create checksum
 sta$02
 lda$f7// Check if load start = load end address
 cmp$f9
 bneC03c8
 lda$f8
 cmp$fa
 beqC03d1// All data loaded
C03c8:inc$f7// Increase load address
 bneC03ce
 inc$f8
C03ce:jmpC03e6// Sets loaded byte to 0xFE and exits IRQ

C03d1:lda#$d9
 staC036e+1// Change jmp to $03d9. Loading done, fetch checksum byte
 jmpC03e6// Sets loaded byte to 0xFE and exits IRQ

// Accessed by SMC JMP after data has been loaded
// Fetches checksum byte
C03d9:bcsexitIRQ
 eor$02
 sta$02
 lda#$71
 staC036e+1// Change jmp to $0371, default value
 sta$fe// flag loading as finished
C03e6:lda#$fe
 sta$fc
exitIRQ:pla
 tay
 pla
 rti

.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20