L'atelier Fabrication d'une flashrom 1024ko à mapper SCC
J'ai une flashrom 1024ko mais c'est en SOP, dur dur à souder
Je l'ai déjà utiliser une en mapper Konami pour ma carte PC Engine.
Je l'ai déjà utiliser une en mapper Konami pour ma carte PC Engine.
Jipe :
le probléme n'est pas l'upgrade a 1024k mais comment programmer un fichier dans 2 flashs différentes avec le même programme
igal :
Et voila! Ca vient tout juste de tomber:
****************************************
Hi Igal,
Yes you can publish the source code on MsxVillage if you want.
I didn't spend time cleaning it up, but it is fairly readable as is.
If people have questions, feel free to ask. I'll keep an eye on
the forum to see if anything comes up and if people post any
improvements (bigger roms for example).
Thanks,
-Daniel
****************************************
Un grand merci à Daniel. Vraiment sympa de sa part.

Son site => http://www.dvik-joyrex.com/
C'est donc une exclusivité du MSXVILLAGE que voici:
Les Sources => leilak.zip
Lâchez vous les gars. C'est noël avant l'heure

****************************************
Hi Igal,
Yes you can publish the source code on MsxVillage if you want.
I didn't spend time cleaning it up, but it is fairly readable as is.
If people have questions, feel free to ask. I'll keep an eye on
the forum to see if anything comes up and if people post any
improvements (bigger roms for example).
Thanks,
-Daniel
****************************************
Un grand merci à Daniel. Vraiment sympa de sa part.

Son site => http://www.dvik-joyrex.com/
C'est donc une exclusivité du MSXVILLAGE que voici:
Les Sources => leilak.zip
Code TEXT :
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
fname "leila_k.rom"
org 4000h
dw 4241h,START,0,0,0,0,0,0
Bank1: equ 05000h
Bank2: equ 07000h
Bank3: equ 09000h
Bank4: equ 0B000h
;SampleFrequency: equ 22050
SampleFrequency: equ 14466
;SampleFrequency: equ 11025
Period: equ 3579545 / SampleFrequency
;-------------------------------------
; Entry point
;-------------------------------------
START:
call powerup
xor a
call 005Fh
di
call VdpTest
jp z,.sc2
call LoadIntro7
call IntroDelay
call LoadScreen7
jp .cont
.sc2:
call LoadIntro2
call IntroDelay
call LoadScreen2
.cont:
ld a,3Fh
LD (Bank3),A
call SccInit
call ReplayerInit
call PlaySynced ; Workaround for SCC defect
ret
IntroDelay:
ei
ld b,100
.loop:
halt
djnz .loop
di
ret
;-------------------------------------
;; Need to wait enough to not access SCC while
;; playing sample 15 and 16. This method takes
;; this into account
;-------------------------------------
PlaySynced:
.aloop:
IF 1
ld b,170
.busywait:
nop
nop
nop
nop
djnz .busywait
ELSE
ld b,140
.busywait2:
nop
nop
nop
nop
djnz .busywait2
ld b,38
ld hl,9800h+32*3
.busywait3:
cp (hl)
cp (hl)
djnz .busywait3
ENDIF
call ReplayerUpdate32
jp .aloop
ret
;-------------------------------------
; Initialize the scc
;-------------------------------------
SccInit:
ld a,15
ld (988Ah),a ; volume ch1
xor a
ld (988Bh),a ; volume ch2
ld (988Ch),a ; volume ch3
ld (988Dh),a ; volume ch4
ld (988Eh),a ; volume ch5
ld a,00011111b ; ALL channels active
ld (988Fh),a
ld hl,9800h+32*3 ; counter in channel 4
ld bc,2000h
.counter:
ld (hl),c
inc hl
inc c
djnz .counter
ld a,10100000b ; Rotate only CH4 & CH5 common waveform. Waveform will be rotated with CH4 freq.
ld (98E0h),a
ld hl,Period
ld (9880h),hl
ld (9886h),hl ; here CH4 restarts its play on emulators
ld (9888h),hl ; here CH4 restarts its play on the real thing
IF 1
ld a,$20
ld (98E0h),a
ENDIF
ret
;-------------------------------------
; Initialize replayer
;-------------------------------------
ReplayerInit:
ld hl,9800h
ld (WavePos),hl
ld hl,6000h
ld (SamplePos),hl
ld a,3
ld (SamplePage),a
ld (Bank2),a
ret
;-------------------------------------
; Moves sample pointer to next page
;-------------------------------------
ReplayerNextPage:
ld hl,6000h
push af
ld a,(SamplePage)
cp (SAMPLE_END - SAMPLE_START + 1FFFh)/2000h
jr nz,.norewind
ld a,2
.norewind:
inc a
ld (SamplePage),a
ld (Bank2),a
pop af
ret
ReplayerUpdate32:
ld hl,(SamplePos)
ld de,9800h
ld bc,16
ldir
push bc
ld b,80
.wait:
djnz .wait
pop bc
push hl
ld hl,Period
ld (9880h),hl
pop hl
ld bc,16
ldir
bit 7,h
call nz,ReplayerNextPage
ld (SamplePos),hl
ret
;-------------------------------------
; Updates the SCC wave table. This method updates
; the entire wave table
;-------------------------------------
ReplayerUpdate32_b:
ld bc,32
ld de,9800h
ld hl,9800h+32*3
ld a,28
.wait:
cp (hl)
jp nz,.wait
ld hl,(SamplePos)
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ld b,100
.loop:
djnz .loop
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
bit 7,h
call nz,ReplayerNextPage
ld (SamplePos),hl
ret
;-------------------------------------
; Powerup routine for non-Z180 code.
; set pages and subslot
;-------------------------------------
powerup:
call 0x138
rrca
rrca
and 0x03
ld c,a
ld b,0
ld hl,0xfcc1
add hl,bc
or (hl)
ld b,a
inc hl
inc hl
inc hl
inc hl
ld a,(hl)
and 0x0c
or b
ld h,0x80
call 0x24
ret
;-------------------------------------
; To make rom guesseres happy
;-------------------------------------
dummy:
xor a
ld (Bank1),a
ld (Bank3),a
ld (Bank1),a
ld (Bank3),a
ret
WrtVdp:
ld a,b
out (99h),a
ld a,c
or 80h
nop
out (99h),a
ret
VdpTest:
ei
ei
halt
di
in a,[99h]
nop
nop
in a,[99h]
push af
ld bc,$010f
call WrtVdp
nop
in a,[99h]
push af
ld bc,$000f
call WrtVdp
pop af
pop bc
sub b
ret
VdpRegs2:
db $02,$a0,$06,$ff,$03,$36,$07,$0f
LoadIntro2:
ld bc,$a001
call WrtVdp
; Load 1st quarter
ld a,0
out (99h),a
ld a,40h
nop
nop
out (99h),a
ld hl,LOGO2_A
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_a:
outi
jp nz,.loop_a
dec a
jp nz,.loop_a
; Load 2nd quarter
ld a,0
out (99h),a
ld a,60h
nop
nop
out (99h),a
ld hl,LOGO2_B
ld de,TempBase
call depack
ld bc,1800h
ld hl,TempBase
.cloop:
ld a,(hl)
and $f0
jp nz,.nofix1
set 4,(hl)
.nofix1:
ld a,(hl)
and $0f
jp nz,.nofix2
set 0,(hl)
.nofix2:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_b:
outi
jp nz,.loop_b
dec a
jp nz,.loop_b
; Vdp register
ld hl,VdpRegs2
ld bc,1899h
ld a,80h
.loop:
outi
nop
nop
out (c),a
inc a
cp 88h
jp nz,.loop
ld bc,$e001
call WrtVdp
ret
LoadScreen2:
ld bc,$a001
call WrtVdp
; Load 1st quarter
ld a,0
out (99h),a
ld a,40h
nop
nop
out (99h),a
ld hl,SC2_A
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_a:
outi
jp nz,.loop_a
dec a
jp nz,.loop_a
; Load 2nd quarter
ld a,0
out (99h),a
ld a,60h
nop
nop
out (99h),a
ld hl,SC2_B
ld de,TempBase
call depack
ld bc,1800h
ld hl,TempBase
.cloop:
ld a,(hl)
and $f0
jp nz,.nofix1
set 4,(hl)
.nofix1:
ld a,(hl)
and $0f
jp nz,.nofix2
set 0,(hl)
.nofix2:
ld a,c
dec a
cp 8
jp nc,.nofix3
ld a,$ff
ld (hl),a
.nofix3:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_b:
outi
jp nz,.loop_b
dec a
jp nz,.loop_b
; Vdp register
ld hl,VdpRegs2
ld bc,1899h
ld a,80h
.loop:
outi
nop
nop
out (c),a
inc a
cp 88h
jp nz,.loop
ld bc,$e001
call WrtVdp
ret
VdpRegsIntro7:
db $06,$62,$1f,$80,$00,$ef,$ff,$07
db $08,$80,$00,$00,$00,$01,$00,$00
db $00,$90,$00,$00,$3b,$05,$00,$00
IF 0
db $06,$60,$1f,$80,$01,$ef,$0f,$07
db $08,$82,$00,$00,$00,$01,$00,$00
db $00,$00,$00,$00,$3b,$05,$00,$00
ENDIF
PaletteIntro:
dw $000,$444,$222,$666,$111,$555,$333,$777
dw $000,$000,$000,$000,$000,$000,$000,$000
LoadIntro7:
ld bc,$a001
call WrtVdp
ld a,1
ld (Bank2),a
; Load 1st quarter
ld a,0
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,LOGO7_A
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_a:
otir
dec a
jp nz,.loop_a
; Load 2nd quarter
ld a,0
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,LOGO7_B
ld de,TempBase
call depack
ld bc,2000h
ld hl,TempBase
.cloop:
ld a,(hl)
and $f0
jp nz,.nofix1
set 7,(hl)
.nofix1:
ld a,(hl)
and $0f
jp nz,.nofix2
set 3,(hl)
.nofix2:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_b:
otir
dec a
jp nz,.loop_b
; Load 3rd quarter
ld a,1
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,LOGO7_C
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_c:
otir
dec a
jp nz,.loop_c
; Load 4th quarter
ld a,1
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,LOGO7_D
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_d:
otir
dec a
jp nz,.loop_d
; Vdp register
ld hl,VdpRegsIntro7
ld bc,1899h
ld a,80h
.loop:
outi
out (c),a
inc a
cp 98h
jp nz,.loop
ld bc,209Ah
ld hl,PaletteIntro
otir
ld bc,$e001
call WrtVdp
ret
VdpRegs7:
db $0a,$a0,$1f,$80,$00,$f7,$1e,$00
db $08,$80,$00,$01,$00,$00,$03,$00
db $00,$00,$00,$00,$3b,$05,$00,$00
Palette:
dw $777,$441,$463,$476,$271,$111,$551,$434
dw $352,$676,$471,$063,$122,$555,$333,$374
LoadScreen7:
ld bc,$a001
call WrtVdp
ld a,1
ld (Bank2),a
ld a,2
ld (Bank3),a
; Load 1st quarter
ld a,0
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,SC7_A
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_a:
otir
dec a
jp nz,.loop_a
; Load 2nd quarter
ld a,0
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,SC7_B
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_b:
otir
dec a
jp nz,.loop_b
; Load 3rd quarter
ld a,1
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,SC7_C
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_c:
otir
dec a
jp nz,.loop_c
; Load 4th quarter
ld a,1
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,SC7_D
ld de,TempBase
call depack
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_d:
otir
dec a
jp nz,.loop_d
ld a,2
ld (Bank2),a
; Load 5th quarter
ld a,4
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,SC7_E
ld de,TempBase
call depack
ld bc,2000h
ld hl,TempBase
.cloop_d:
ld a,l
and $7f
cp $7f
jp nz,.nofix_d
ld a,$00
ld (hl),a
.nofix_d:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop_d
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_e:
otir
dec a
jp nz,.loop_e
; Load 6th quarter
ld a,4
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,SC7_F
ld de,TempBase
call depack
ld bc,2000h
ld hl,TempBase
.cloop_f:
ld a,l
and $7f
cp $7f
jp nz,.nofix_f
ld a,$00
ld (hl),a
.nofix_f:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop_f
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_f:
otir
dec a
jp nz,.loop_f
; Load 7th quarter
ld a,5
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,40h
out (99h),a
ld hl,SC7_G
ld de,TempBase
call depack
ld bc,2000h
ld hl,TempBase
.cloop_g:
ld a,l
and $7f
cp $7f
jp nz,.nofix_g
ld a,$00
ld (hl),a
.nofix_g:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop_g
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_g:
otir
dec a
jp nz,.loop_g
; Load 8th quarter
ld a,5
out (99h),a
ld a,8Eh
out (99h),a
ld a,0
out (99h),a
ld a,60h
out (99h),a
ld hl,SC7_H
ld de,TempBase
call depack
ld bc,2000h
ld hl,TempBase
.cloop_h:
ld a,l
and $7f
cp $7f
jp nz,.nofix_h
ld a,$00
ld (hl),a
.nofix_h:
inc hl
dec bc
ld a,b
or c
jp nz,.cloop_h
ld hl,TempBase
ld bc,0098h
ld a,20h
.loop_h:
otir
dec a
jp nz,.loop_h
; Vdp register
ld hl,VdpRegs7
ld bc,1899h
ld a,80h
.loop:
outi
out (c),a
inc a
cp 98h
jp nz,.loop
ld bc,209Ah
ld hl,Palette
otir
ld bc,$e001
call WrtVdp
ret
include "bitbuster.asm"
SC2_A:
incbin "sc2_a.bin.pck"
SC2_B:
incbin "sc2_b.bin.pck"
LOGO2_A:
incbin "logo2_a.bin.pck"
LOGO2_B:
incbin "logo2_b.bin.pck"
;-------------------------------------
; Padding for rom player
;-------------------------------------
DS (6000h - $)
LOGO7_A:
incbin "logo5_a.bin.pck"
LOGO7_B:
incbin "logo5_b.bin.pck"
LOGO7_C:
incbin "logo5_c.bin.pck"
LOGO7_D:
incbin "logo5_d.bin.pck"
SC7_A:
incbin "sc7_a.bin.pck"
SC7_B:
incbin "sc7_b.bin.pck"
SC7_C:
incbin "sc7_c.bin.pck"
SC7_D:
incbin "sc7_d.bin.pck"
SC7_E:
incbin "sc7_e.bin.pck"
SC7_F:
incbin "sc7_f.bin.pck"
SC7_G:
incbin "sc7_g.bin.pck"
SC7_H:
incbin "sc7_h.bin.pck"
DS (0A000h - $)
;-------------------------------------
; Sample data
;-------------------------------------
SAMPLE_START:
;incbin "ll2.raw",0,7A000h
incbin "ll2.raw"
SAMPLE_END:
;-------------------------------------
; Padding, align rom image to a power of two.
;-------------------------------------
SAMPLE_LENGTH: equ SAMPLE_END - SAMPLE_START
DS (7A000h - SAMPLE_LENGTH)
FINISH:
;---------------------------------------------------------
; Variables
;---------------------------------------------------------
TempBase: equ $c000
VariableBase: equ $e000
WavePos: equ VariableBase + 0
SamplePos: equ VariableBase + 2
SamplePage: equ VariableBase + 4
Lâchez vous les gars. C'est noël avant l'heure

Metalion :
Bon, j'ai analysé en vitesse les sources de LEILA K.
Les fichiers .pck sont des fichiers compressés par Bitbuster (compression LZ donc) qui ne contiennent que les éléments graphiques de la démo.
Le fichier .raw contient la source sonore à la fréquence d'échantillonnage 14466Hz, mais cette fréquence est modifiable dans les sources.
Le replayer fonctionne comme suit :
- il sélectionne une page de la ROM pour le bank 2 ($6000 - $7FFF)
- il envoie les données sur le premier canal de la SCC, par paquet de 32 octets
- quand il arrive à la fin de la page, il réinitialise le compteur et charge la page suivant dans le bank 2
- quand il arrive à la fin du morceau, il reboucle.
La difficulté en ce qui concerne la modification de la fréquence d'échantillonnage vient du fait qu'il faut synchroniser totalement le code avec la SCC. Autrement dit, il faut que lorsque la SCC a fini de jouer une première fois le sample (à la fréquence pré-définie), le code arrive juste à temps pour mettre à jour le sample avec les données suivantes avant que la SCC reboucle.
Il y a un peu de latitude (il y a une petite boucle d'attende djnz entre chaque mise à jour), mais je ne suis pas sur que l'on puisse aller très loin dans la fréquence d'échantillonnage (à vérifier).
En ce qui concerne la taille maximale du morceau, théoriquement, on peut avoir jusqu'à 254 pages de 8Kb (il faut en garder une pour le code et une pour la SCC). Donc 254x8=2032Kb, ce qui donne 144 secondes (2minutes 24 secondes) à la fréquence de 14466Hz.
Les fichiers .pck sont des fichiers compressés par Bitbuster (compression LZ donc) qui ne contiennent que les éléments graphiques de la démo.
Le fichier .raw contient la source sonore à la fréquence d'échantillonnage 14466Hz, mais cette fréquence est modifiable dans les sources.
Le replayer fonctionne comme suit :
- il sélectionne une page de la ROM pour le bank 2 ($6000 - $7FFF)
- il envoie les données sur le premier canal de la SCC, par paquet de 32 octets
- quand il arrive à la fin de la page, il réinitialise le compteur et charge la page suivant dans le bank 2
- quand il arrive à la fin du morceau, il reboucle.
La difficulté en ce qui concerne la modification de la fréquence d'échantillonnage vient du fait qu'il faut synchroniser totalement le code avec la SCC. Autrement dit, il faut que lorsque la SCC a fini de jouer une première fois le sample (à la fréquence pré-définie), le code arrive juste à temps pour mettre à jour le sample avec les données suivantes avant que la SCC reboucle.
Il y a un peu de latitude (il y a une petite boucle d'attende djnz entre chaque mise à jour), mais je ne suis pas sur que l'on puisse aller très loin dans la fréquence d'échantillonnage (à vérifier).
En ce qui concerne la taille maximale du morceau, théoriquement, on peut avoir jusqu'à 254 pages de 8Kb (il faut en garder une pour le code et une pour la SCC). Donc 254x8=2032Kb, ce qui donne 144 secondes (2minutes 24 secondes) à la fréquence de 14466Hz.
Pour ceux qui connaissent pas:
Il ne manque plus qu'un connaisseur qui ait envi d'y passer du temps je crois

Plus d'infos par ici => http://www.msxvillage.fr/forum/topic.php?id=1418&pt=1 Edité par igal Le 29/05/2013 à 00h23
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie


