Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Assembles with Zeus Next, from http://www.desdes.com/products/oldfiles/zeustest.exe
- zeusemulate "Next", "RAW"
- org $8000
- SetupCopperFlash. proc
- CopperControl(%00, 0) ; Stop the copper and position to program index 0
- ld b, CopperFlash.Count ; Count is the number of words in the program,
- ld hl, CopperFlash.Program ; coded like this so b is 180, which is < 256
- ProgramLoop: ld a, (hl) ; Read pairs of copper instruction bytes
- nextreg $60, a ; And write them to the copper program register
- inc hl
- ld a, (hl)
- nextreg $60, a
- inc hl
- djnz ProgramLoop ; DJNZ is why b is better < 256
- ld bc, CopperFlash.Empty ; Empty is the count of unused instruction pairs
- EmptyLoop: nextreg $60, 0 ; Write NOPs for every unused byte
- dec bc ; in the 1024-instruction program
- ld a, b ; (total 2048 bytes)
- or c
- jp nz, EmptyLoop ; Again, b is 166, which is < 256
- CopperControl(%01, 0) ; Finally turn the copper on. It will run
- ret ; without attention as long as NXtel is running.
- pend
- CopperFlash proc Program:
- CopperWait(0, 192, 32) ; Wait for 32 frames, ending on line 192
- CopperMove($43, %0 001 000 0, 1) ; Set Layer 2 primary palette, incrementing
- CopperMove($40, 64, 1) ; Start writing palette entries at index 64
- CopperPalette(64, 8) ; Redefine as background (8 of each colour)
- CopperWait(0, 192, 16) ; Wait for another 16 frames, ending on line 192
- CopperMove($43, %0 001 000 0, 1) ; Set Layer 2 primary palette, incrementing
- CopperMove($40, 64, 1) ; Start writing palette entries at index 64
- CopperPalette(64, 1) ; Redefine as foreground (1 of each colour)
- Size equ $-Program ; This program will run forever,
- Count equ Size/2 ; restarting automatically every 48 frames.
- Empty equ 2048-Size
- pend
- CopperControl macro(Command, Position)
- nextreg $62, ((Command & %11) << 6) | ((high Position) & %111)
- nextreg $61, low Position
- mend
- CopperNOP macro(Iterations)
- ds Iterations*2
- mend
- CopperHalt macro()
- dw $FFFF
- mend
- CopperWait macro(X, Y, Frames)
- for n = Y+Frames-1 to Y step -1
- db %10000000 | ((X & %111111) << 1) | ((high n) & %1)
- db low n
- next ;n
- mend
- CopperMove macro(Reg, Val, Iterations)
- for n = 1 to Iterations
- db Reg & %01111111
- db Val & %11111111
- next ;n
- mend
- CopperPalette macro(Iterations, Each)
- for n = 0 to Iterations - 1
- db $41 ; 8-bit palette register
- db TeletextColour(n / Each) ; 8-bit teletext colour value (RRRGGGBB)
- next ;n
- mend
- [[
- function TeletextColour(Value)
- begin
- if (Value mod 8) = 0
- return %000 000 00 ; 0 Black The layer 2 primary palette repeats these
- if (Value mod 8) = 1
- return %111 000 00 ; 1 Red 8 colours 32 times through indices 0..255.
- if (Value mod 8) = 2
- return %000 111 00 ; 2 Green
- if (Value mod 8) = 3
- return %111 111 00 ; 3 Yellow
- if (Value mod 8) = 4
- return %001 001 11 ; 4 Blue Lightened for readability on black background.
- if (Value mod 8) = 5
- return %111 001 11 ; 5 Magenta Uses $E7 because global transparency is $E3.
- if (Value mod 8) = 6
- return %000 111 11 ; 6 Cyan
- return %111 111 11 ; 7 White
- end
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement