First attempt at HAM mode

This commit is contained in:
alpine9000 2016-03-07 20:26:44 +11:00
parent 2548f4c5c5
commit 1cc6f7aebe
8 changed files with 139 additions and 0 deletions

10
012.ham_mode/Makefile Normal file
View File

@ -0,0 +1,10 @@
MODULE=ham_mode.s
FLOPPY=bin/ham_mode.adf
IMAGEDATA=out/image-palette.s out/image-ham.bin
IMAGEFILE=../assets/gigi.png
EXTRA=$(IMAGEDATA) $(BOB_IMAGEDATA) init.s utils.s constants.i Makefile
include ../shared/base.mk
$(IMAGEDATA): $(IMAGECON) $(IMAGEFILE) Makefile
$(IMAGECON) --input $(IMAGEFILE) --output out/image --ham --output-bitplanes --output-palette-asm

8
012.ham_mode/README.md Normal file
View File

@ -0,0 +1,8 @@
Hold and Modify Mode
====================
I added basic supprt to [imagecon](../tools/imagecon) to output HAM mode data. The algorithm used is pretty simple so the quality of the HAM display could definately be improved.
[Download disk image](bin/ham_mode.adf?raw=true)

Binary file not shown.

10
012.ham_mode/constants.i Normal file
View File

@ -0,0 +1,10 @@
LVL3_INT_VECTOR equ $6c
SCREEN_WIDTH equ 320
SCREEN_HEIGHT equ 256
SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8)
SCREEN_BIT_DEPTH equ 6
SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution
RASTER_X_START equ $81 ; hard coded coordinates from hardware manual
RASTER_Y_START equ $2c
RASTER_X_STOP equ RASTER_X_START+SCREEN_WIDTH
RASTER_Y_STOP equ RASTER_Y_START+SCREEN_HEIGHT

42
012.ham_mode/ham_mode.s Normal file
View File

@ -0,0 +1,42 @@
include "../include/registers.i"
include "hardware/dmabits.i"
include "hardware/intbits.i"
include "constants.i"
entry:
lea CUSTOM,a6
bsr init
bsr.s installColorPalette
.mainLoop:
bsr waitVerticalBlank
bra .mainLoop
include "init.s"
include "utils.s"
installColorPalette:
include "out/image-palette.s"
rts
copper:
;; bitplane pointers must be first else poking addresses will be incorrect
dc.w BPL1PTL,0
dc.w BPL1PTH,0
dc.w BPL2PTL,0
dc.w BPL2PTH,0
dc.w BPL3PTL,0
dc.w BPL3PTH,0
dc.w BPL4PTL,0
dc.w BPL4PTH,0
dc.w BPL5PTL,0
dc.w BPL5PTH,0
dc.w BPL6PTL,0
dc.w BPL6PTH,0
dc.l $fffffffe
bitplanes:
incbin "out/image-ham.bin"
;; incbin "out/image.bin"

43
012.ham_mode/init.s Normal file
View File

@ -0,0 +1,43 @@
include "../include/bplconbits.i"
;; custom chip base globally in a6
init:
movem.l d0-a6,-(sp)
move #$7ff,DMACON(a6) ; disable all dma
move #$7fff,INTENA(a6) ; disable all interrupts
;; set up default palette
bsr.s installColorPalette
;; set up playfield
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
move.w #((RASTER_Y_STOP-256)<<8)|(RASTER_X_STOP-256),DIWSTOP(a6)
move.w #(RASTER_X_START/2-SCREEN_RES),DDFSTRT(a6)
move.w #(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1)),DDFSTOP(a6)
;; move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON|HOMOD,BPLCON0(a6)
move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON|HOMOD,BPLCON0(a6)
move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6)
move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL2MOD(a6)
;; poke bitplane pointers
lea bitplanes(pc),a1
lea copper(pc),a2
moveq #SCREEN_BIT_DEPTH-1,d0
.bitplaneloop:
move.l a1,d1
move.w d1,2(a2)
swap d1
move.w d1,6(a2)
lea SCREEN_WIDTH_BYTES(a1),a1 ; bit plane data is interleaved
addq #8,a2
dbra d0,.bitplaneloop
;; install copper list, then enable dma and selected interrupts
lea copper(pc),a0
move.l a0,COP1LC(a6)
move.w COPJMP1(a6),d0
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
;; move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
movem.l (sp)+,d0-a6
rts

23
012.ham_mode/utils.s Normal file
View File

@ -0,0 +1,23 @@
waitVerticalBlank:
movem.l d0-a6,-(sp)
.loop move.l $dff004,d0
and.l #$1ff00,d0
cmp.l #303<<8,d0
bne.b .loop
movem.l (sp)+,d0-a6
rts
waitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0.
movem.l d0-a6,-(sp)
move.l #$1ff00,d2
lsl.l #8,d0
and.l d2,d0
lea $dff004,a0
.wr: move.l (a0),d1
and.l d2,d1
cmp.l d1,d0
bne.s .wr
movem.l (sp)+,d0-a6
rts

3
include/bplconbits.i Normal file
View File

@ -0,0 +1,3 @@
COLOR_ON equ $200
LACE equ $004
HOMOD equ $800