after weeks of trying to search what was wrong I still cannot figure out how to make those color palettes.
If anyone manage to figure out what did I done wrong please explain it to me.
MEGAMAN X SIGMA'S WARS.X68 (the main file)
Code: Select all
INCLUDE Initialisation.X68
INCLUDE VDP_RAM.X68
INCLUDE VDP_registre.X68
INCLUDE header.X68
INCLUDE Carte_memoire.X68
VDP_SET_ADDR VDP_CRAM_WRITE,$0000
VDP_SET_REG VDP_REG_AUTOINC,2
move.w #$01,d0
LEA.L PaletteX,A0
INCLUDE Palettes.X68
INCLUDE PaletteRoutine.X68
__end:
Code: Select all
;nettoyage RAM
MOVE.L #$00000000,D0
MOVE.L #$00000000,A0
MOVE.L #$00003FFF,D1
ClearRAM:
MOVE.L D0,-(A0)
DBRA D1,ClearRAM
InitVDP:
lea.L VDPInitDataStart,a0 ; load the address of the VDP init data to a0
move.w #(VDPInitDataEnd-VDPInitDataStart)/2,d1 ; length of init data to d1
InitVDPDataLoop:
move.w (a0)+,(VDP_CONTROL) ; write the init data
dbf d1,InitVDPDataLoop ; decrement value of d1 and loop if not 0
; clear VRAM - prevents garbage tiles from showing at boot on clone systems
bsr.w ClearVRAM ; clear VRAM
ClearVRAM:
move.l #VDP_VRAM_WRITE,(VDP_CONTROL)
move.w #$7FFF,d1
ClearVRAMLoop:
move.w #$0000,(VDP_DATA)
dbra d1,ClearVRAMLoop
rts
;VDP initialisation
MOVE.L #VDPRegisters,A0
MOVE.L #$18,D0
MOVE.L #$00008000,D1
CopyVDP:
MOVE.B (A0)+,D1
MOVE.W D1,VDP_CONTROL
ADD.W #$0100,D1
DBRA D0,CopyVDP
;Z80 initialisation
MOVE.W #$0100,Z80_BUS_REQ
MOVE.W #$0100,Z80_RESET
WAIT:
BTST #$0,Z80_BUS_GRANT
BNE WAIT
MOVE.L #Z80_RAM,A1
MOVE.L #$00C30000,(A1)
MOVE.W #$0000,Z80_RESET
MOVE.W #$0000,Z80_BUS_REQ
Code: Select all
VDPInitDataStart:
dc.w $8004
dc.w $8174
dc.w $8230
dc.w $8328
dc.w $8407
dc.w $855C
dc.w $8600
dc.w $8700
dc.w $8800
dc.w $8900
dc.w $8A00
dc.w $8B00
dc.w $8C81
dc.w $8E00
dc.w $8F02
dc.w $9001
dc.w $9100
dc.w $9200
dc.w $93FF
dc.w $94FF
dc.w $9500
dc.w $9600
dc.w $9780
VDPInitDataEnd:
Code: Select all
VDPRegisters:
VDPReg0: dc.b $14 ; 0: H interrupt on, palettes on
VDPReg1: dc.b $74 ; 1: V interrupt on, display on, DMA on,
; Genesis mode on
VDPReg2: dc.b $30 ; 2: Pattern table for Scroll Plane A
; at VRAM $C000
; (bits 3-5 = bits 13-15)
VDPReg3: dc.b $00 ; 3: Pattern table for Window Plane
; at VRAM $0000
; (disabled) (bits 1-5 = bits 11-15)
VDPReg4: dc.b $07 ; 4: Pattern table for Scroll Plane B
; at VRAM $E000
; (bits 0-2 = bits 11-15)
VDPReg5: dc.b $78 ; 5: Sprite table at VRAM $F000
; (bits 0-6 = bits 9-15)
VDPReg6: dc.b $00 ; 6: Unused
VDPReg7: dc.b $00 ; 7: Background colour - bit 0-3 = colour,
; bits 4-5 = palette
VDPReg8: dc.b $00 ; 8: Unused
VDPReg9: dc.b $00 ; 9: Unused
VDPRegA: dc.b $FF ; 10: Frequency of Horiz. interrupt in
; Rasters (number of lines travelled by
; the beam)
VDPRegB: dc.b $00 ; 11: External interrupts off,
; V scroll fullscreen,
; H scroll fullscreen
VDPRegC: dc.b $81 ; 12: Shadows and highlights off,
; interlace off,
; H40 mode (320 x 224 screen res)
VDPRegD: dc.b $3F ; 13: Horiz. scroll table at VRAM $FC00
; (bits 0-5)
VDPRegE: dc.b $00 ; 14: Unused
VDPRegF: dc.b $02 ; 15: Autoincrement 2 bytes
VDPReg10: dc.b $01 ; 16: Vert. scroll 32, Horiz. scroll 64
VDPReg11: dc.b $00 ; 17: Window Plane X pos 0 left
; (pos in bits 0-4, left/right in bit 7)
VDPReg12: dc.b $00 ; 18: Window Plane Y pos 0 up
; (pos in bits 0-4, up/down in bit 7)
VDPReg13: dc.b $FF ; 19: DMA length lo byte
VDPReg14: dc.b $FF ; 20: DMA length hi byte
VDPReg15: dc.b $00 ; 21: DMA source address lo byte
VDPReg16: dc.b $00 ; 22: DMA source address mid byte
VDPReg17: dc.b $80 ; 23: DMA source address hi byte,
; memory-to-VRAM mode (bits 6-7)
Code: Select all
rom_header:
dc.l $00FFFFFE ; Initial stack pointer value
dc.l init ; Initial program counter value
dc.l ignore_handler ; Bus error
dc.l ignore_handler ; Address error
dc.l ignore_handler ; Illegal instruction
dc.l ignore_handler ; Division by zero
dc.l ignore_handler ; CHK exception
dc.l ignore_handler ; TRAPV exception
dc.l ignore_handler ; Privilege violation
dc.l ignore_handler ; TRACE exception
dc.l ignore_handler ; Line-A emulator
dc.l ignore_handler ; Line-F emulator
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Spurious exception
dc.l ignore_handler ; IRQ level 1
dc.l ignore_handler ; IRQ level 2
dc.l ignore_handler ; IRQ level 3
dc.l ignore_handler ; IRQ level 4 (horiz. retrace int.)
dc.l ignore_handler ; IRQ level 5
dc.l ignore_handler ; IRQ level 6 (vert. retrace int.)
dc.l ignore_handler ; IRQ level 7
dc.l ignore_handler ; TRAP #00 exception
dc.l ignore_handler ; TRAP #01 exception
dc.l ignore_handler ; TRAP #02 exception
dc.l ignore_handler ; TRAP #03 exception
dc.l ignore_handler ; TRAP #04 exception
dc.l ignore_handler ; TRAP #05 exception
dc.l ignore_handler ; TRAP #06 exception
dc.l ignore_handler ; TRAP #07 exception
dc.l ignore_handler ; TRAP #08 exception
dc.l ignore_handler ; TRAP #09 exception
dc.l ignore_handler ; TRAP #10 exception
dc.l ignore_handler ; TRAP #11 exception
dc.l ignore_handler ; TRAP #12 exception
dc.l ignore_handler ; TRAP #13 exception
dc.l ignore_handler ; TRAP #14 exception
dc.l ignore_handler ; TRAP #15 exception
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
ignore_handler:
RTE
INIT:
MOVE #$2700,sr
DC.B 'SEGA MEGA DRIVE ' ; Console name
dc.b '(C) MA ' ; Copyrght holder and release date
dc.b 'BOOT LOGO '
; Domest. name
dc.b 'BOOT LOGO '
; Intern. name
dc.b '2019-01-20 ' ; Version number
dc.w $0000 ; Checksum
dc.b 'J ' ; I/O support
dc.l $00000000 ; Start address of ROM
dc.l __end ; End address of ROM
dc.l $00FF0000 ; Start address of RAM
dc.l $00FFFFFF ; End address of RAM
dc.l $00000000 ; SRAM enabled
dc.l $00000000 ; Unused
dc.l $00000000 ; Start address of SRAM
dc.l $00000000 ; End address of SRAM
dc.l $00000000 ; Unused
dc.l $00000000 ; Unused
dc.b ' ' ; Notes
dc.b 'JUE ' ; Country codes (Japan, USA, Europe)
move.b $00A10001,d0 ; Move Megadrive hardware ver. to d0
andi.b #$0F,d0 ; Version is stored in last four bits
; so mask it with 0F
beq Skip ; If version = 0, skip TMSS signature
move.l #'SEGA',$00A14000 ; Move string "SEGA" to $A14000
Skip:
Code: Select all
; 68k memory map
CTRL_1_DATA EQU $00A10003
CTRL_2_DATA EQU $00A10005
CTRL_X_DATA EQU $00A10007
CTRL_1_CONTROL EQU $00A10009
CTRL_2_CONTROL EQU $00A1000B
CTRL_X_CONTROL EQU $00A1000D
REG_HWVERSION EQU $00A10001
REG_TMS EQU $00A14000
PSG_INPUT EQU $00C00011
RAM_START EQU $00FF0000
VDP_DATA EQU $00C00000
VDP_CONTROL EQU $00C00004
VDP_COUNTER EQU $00C00008
Z80_ADDRESS_SPACE EQU $00A10000
Z80_BUS_REQ EQU $00A11100
Z80_BUS_GRANT EQU $00A11101
Z80_RESET EQU $00A11200
Z80_RAM EQU $00A00000
; VDP access modes
VDP_SET_REG MACRO
MOVE.W #((($80|\1)<<8)|\2),vdp_control
ENDM
VDP_CRAM_READ EQU %001000
VDP_CRAM_WRITE EQU %000011
VDP_VRAM_READ EQU %000000
VDP_VRAM_WRITE EQU %000001
VDP_VSRAM_READ EQU %000100
VDP_VSRAM_WRITE EQU %000101
VDP_REG_AUTOINC EQU 15
VDP_SET_ADDR MACRO
MOVE.L #((\1&%11)<<30|(\2&%11111111111111)<<16|(\1&%11100)<<2|(\2>>14)),vdp_control
ENDM
VDP_WRITE_DATA MACRO
MOVE.W \1,VDP_DATA
ENDM
; VDP status
VDP_STATUS_FIFO_EMPTY EQU $0200
VDP_STATUS_FIFO_FULL EQU $0100
VDP_STATUS_VINT_PENDING EQU $0080
VDP_STATUS_SPRITE_OVERFLOW EQU $0040
VDP_STATUS_SPRITE_COLLISION EQU $0020
VDP_STATUS_ODD_FRAME EQU $0010
VDP_STATUS_VBLANK EQU $0008
VDP_STATUS_HBLANK EQU $0004
VDP_STATUS_DMA EQU $0002
VDP_STATUS_PAL EQU $0001
; buttons
BUTTON_UP_PRESSED EQU $01
BUTTON_DOWN_PRESSED EQU $02
BUTTON_LEFT_PRESSED EQU $04
BUTTON_RIGHT_PRESSED EQU $08
BUTTON_B_PRESSED EQU $10
BUTTON_C_PRESSED EQU $20
BUTTON_A_PRESSED EQU $40
BUTTON_START_PRESSED EQU $80
Code: Select all
PaletteX:
DC.W $0C80,$0000,$000C,$0899
DC.W $0F84,$0FA5,$0F01,$0FC6
DC.W $0F80,$0777,$08AF,$006F
DC.W $0C40,$0EEE,$0B02,$0000
PaletteRoutine.X68
CODE: SELECT ALL
ChargementPalette:
MOVE.L D1,(VDP_CONTROL)
MULU #$10,D0
SUB.W #$01,D0
ChargementPaletteBoucle:
MOVE.W (A0)+,(VDP_DATA)
DBF D0,ChargementPaletteBoucle
RTS