Compare commits

..

No commits in common. "main" and "fb-accel" have entirely different histories.

13 changed files with 39 additions and 205 deletions

View file

@ -9,11 +9,11 @@ Registers
| _FB_PS_ | $90C | Palette Select |
| _FB_PD_ | $910 | Palette Data |
| _FB_CTL_ | $914 | Control Register |
| _FB_SHIFTER_ | $918 | Shift Assist Register |
| _FB_SHIFTCOUNT_ | $91C | Shift Count Register |
| _FB_SHIFTERM_ | $920 | Shifted Mask Register |
| _FB_SHIFTERSP_ | $924 | Shifter Spill Register |
| _FB_MASKGEN_ | $928 | Mask Generator Register |
| _FB_SHIFTER | $918 | Shift Assist Register |
| _FB_SHIFTCOUNT | $91C | Shift Count Register |
| _FB_SHIFTERM | $920 | Shifted Mask Register |
| _FB_SHIFTERSP | $924 | Shifter Spill Register |
| _FB_MASKGEN | $928 | Mask Generator Register |
## Pixel Data
Pixel data is organized in 32-bit-words. With four bits per pixel, one word
@ -121,12 +121,12 @@ For each four bits of a pixel, the corresponding four mask bits
are all set to one if the pixel value is not zero.
This can be used to combine foreground and background pixel data
where a pixel value of zero is used to indicate a transparent foreground pixel.
with a pixel value of zero for a transparent background color.
Usually, the mask will be inverted with a *NOT* instruction.
The result can then be used to clear all pixels in the background
that are set in the foreground, using an *AND* instruction.
As the last step, foreground and masked background data can be combined with an *OR* instruction.
Usually, the mask will be inverted with a *NOT* instruction
to clear all pixels in the background that are set in the foreground
with an *AND* instruction
before *ORing* foreground and background together.
Example in hexadecimal, each digit is a pixel:
| Pixel Data | Mask |

View file

@ -1,5 +1,5 @@
program animate;
uses sprites,pcmaudio;
uses sprites;
type PictData = record
magic,mode:integer;
@ -9,13 +9,12 @@ type PictData = record
Sprite = record
x,y:integer;
oldX,oldY:integer;
xdelta,ydelta:integer;
curFrame:integer;
frameCount:integer;
frameTime:integer;
frameLeft:integer;
moveTime:integer;
moveLeft:integer;
changed:boolean;
frame:array [0..3] of SpritePixels;
end;
@ -26,36 +25,9 @@ var pic:PictData;
ch:char;
stickMan:Sprite;
rocket:Sprite;
rocket2:Sprite;
rocket3:Sprite;
buf:SndBufPtr;
procedure WaitVSync; external;
function readAudioFile(fname:string):SndBufPtr;
var i,size:integer;
c:char;
buf:SndBufPtr;
f:file;
begin
open(f, fname, ModeReadOnly);
size := FileSize(f);
new(buf, size);
buf^ := '';
write('Reading ', size, ' bytes from ', fname);
for i := 1 to size do
begin
read(f,c);
AppendChar(buf^,c);
end;
writeln;
close(f);
readAudioFile := buf;
end;
procedure loadPalette(var pic:PictData);
var i:integer;
begin
@ -83,95 +55,63 @@ end;
procedure animateSprite(var aSprite:Sprite);
var frameIndex:integer;
frameTime,frameLeft:integer;
moveTime,moveLeft:integer;
ydelta:integer;
oldX,oldY:integer;
begin
ydelta := aSprite.ydelta;
frameIndex := aSprite.curFrame;
frameTime := aSprite.frameTime;
frameLeft := aSprite.frameLeft;
moveTime := aSprite.moveTime;
moveLeft := aSprite.moveLeft;
oldX := aSprite.x; oldY := aSprite.y;
aSprite.oldX := oldX; aSprite.oldY := oldY;
frameLeft := frameLeft - 1;
if frameLeft <= 0 then
begin
frameIndex := frameIndex + 1;
frameLeft := frameTime;
frameLeft := aSPrite.frameTime;
aSprite.frameLeft := frameLeft;
aSprite.curFrame := frameIndex;
if frameIndex >= aSprite.frameCount then
aSprite.curFrame := 0;
end;
moveLeft := moveLeft - 1;
if moveLeft <= 0 then
begin
aSprite.frameLeft := frameLeft;
aSprite.x := aSprite.x + aSprite.xdelta;
aSprite.y := aSprite.y + aSprite.ydelta;
moveLeft := moveTime;
if aSprite.x > 608 then aSprite.x := 0;
if aSprite.ydelta <> 0 then
if aSprite.y < 0 then
begin
if aSprite.y < 3 then
aSprite.ydelta := -aSprite.ydelta
else
if aSprite.y > 130 then
aSprite.ydelta := -aSprite.yDelta;
aSprite.y := 200;
aSprite.x := 0;
end;
end;
aSprite.frameLeft := frameLeft;
aSprite.moveLeft := moveLeft;
end;
procedure animLoop;
var i:integer;
oldX,oldY:integer;
roldX,roldY:integer;
r2oldX,r2oldY:integer;
r3oldX,r3oldY:integer;
begin
stickMan.x := 0;
stickMan.y := 205;
stickMan.y := 310;
stickMan.frameTime := 6;
stickMan.frameLeft := stickMan.frameTime;
stickMan.curFrame := 0;
stickMan.xdelta := 2;
stickMan.ydelta := 0;
stickMan.moveTime := 2;
stickman.moveLeft := stickMan.moveTime;
rocket.x := 0;
rocket.y := 50;
rocket.frameTime := 5;
rocket.y := 200;
rocket.frameTime := 1;
rocket.frameLeft := rocket.frameTime;
rocket.curFrame := 0;
rocket.xdelta := 3;
rocket.ydelta := 1;
rocket.moveTime := 1;
rocket.moveLeft := rocket.moveTime;
rocket2.x := 50;
rocket2.y := 190;
rocket2.frameTime := 5;
rocket2.frameLeft := rocket2.frameTime;
rocket2.curFrame := 1;
rocket2.xdelta := 3;
rocket2.ydelta := 0;
rocket2.moveTime := 1;
rocket2.moveLeft := rocket2.moveTime;
rocket3.x :=100;
rocket3.y := 90;
rocket3.frameTime := 5;
rocket3.frameLeft := rocket3.frameTime;
rocket3.curFrame := 2;
rocket3.xdelta := 3;
rocket3.ydelta := -1;
rocket3.moveTime := 1;
rocket3.moveLeft := rocket3.moveTime;
rocket.xdelta := 2;
rocket.ydelta := -1;
while not ConAvail do
begin
@ -181,29 +121,17 @@ begin
roldX := rocket.x;
roldY := rocket.y;
r2oldX := rocket2.x;
r2oldY := rocket2.y;
r3oldX := rocket3.x;
r3oldY := rocket3.y;
PutSprite(roldX, roldY, rocket.frame[rocket.curFrame]);
PutSprite(r2oldX, r2oldY, rocket2.frame[rocket2.curFrame]);
PutSprite(r3oldX, r3oldY, rocket3.frame[rocket3.curFrame]);
PutSprite(oldX, oldY, stickMan.frame[stickMan.curFrame]);
animateSprite(rocket);
animateSprite(rocket2);
animateSprite(rocket3);
animateSprite(stickMan);
Delay(10);
{Delay(1);}
WaitVSync;
UndrawSprite(oldX, oldY, pic.pixeldata);
UndrawSprite(roldX, roldY, pic.pixeldata);
UndrawSprite(r2oldX, r2oldY, pic.pixeldata);
UndrawSprite(r3oldX, r3oldY, pic.pixeldata);
end;
end;
@ -232,14 +160,5 @@ begin
loadSpriteFrame(rocket, 3, infile, 3);
close(infile);
rocket2 := rocket;
rocket3 := rocket;
buf := readAudioFile('footsteps.tdrau');
SampleQStart(buf, true, 16000);
animLoop;
SampleQStop;
dispose(buf);
end.

Binary file not shown.

View file

@ -1,19 +0,0 @@
JASC-PAL
0100
16
0 0 0
255 255 255
255 0 0
0 255 0
0 0 255
0 255 255
255 0 255
255 255 0
127 127 127
160 160 160
127 0 0
0 127 0
0 0 127
0 127 127
127 0 127
127 127 0

View file

@ -106,7 +106,7 @@ begin
end;
begin
readSpriteData('sprite-testcard.sprt');
readSpriteData('rocket.sprt');
InitGraphics;
startBench('points 200K');

Binary file not shown.

Binary file not shown.

View file

@ -53,9 +53,9 @@ CALC_VMEM_ADDR:
.EQU PS_SPILL 24
.EQU PS_STRIPE_C 28
.EQU PS_BPSAVE 32
.EQU PS_FS_ 36
.EQU PS_FS 36
PUTSPRITE:
FPADJ -PS_FS_
FPADJ -PS_FS
STORE PS_SPRITE_DATA
STORE PS_Y
STORE PS_X
@ -175,7 +175,7 @@ PS_L_XT:
LOAD PS_BPSAVE
STOREREG BP
FPADJ PS_FS_
FPADJ PS_FS
RET
; undraw a sprite, i.e. draw background data

Binary file not shown.

View file

@ -977,7 +977,7 @@ SETPALETTE:
DEFAULT_PALETTE:
.WORD 0, $FFF, $F00, $0F0, $00F, $0FF, $F0F, $FF0
.WORD $777, $AAA, $700, $070, $007, $077, $707, $770
.WORD $777, $777, $700, $070, $007, $077, $707, $770
; set whole video memory to zero
CLEARGRAPHICS:

View file

@ -249,7 +249,6 @@ func (c *CPU) step() error {
var name string
if (insWord & 1) == 1 {
name = "STORE.B"
operand &= ^1
ea = c.BP + word(operand)
} else {
name = "STORE"

View file

@ -10,16 +10,11 @@ import (
const VmemWords = 32768
const PaletteSlots = 16
const FB_RA = 0
const FB_WA = 4
const FB_IO = 8
const FB_PS = 12
const FB_PD = 16
const FB_CTL= 20
const FB_SHIFTER = 24
const FB_SHIFTCOUNT = 28
const FB_SHIFTERM = 32
const FB_SHIFTERSP = 36
const FB_MASKGEN = 40
const FB_WA = 1
const FB_IO = 2
const FB_PS = 3
const FB_PD = 4
const FB_CTL= 5
const PixelMask = 0b11110000000000000000000000000000
const PixelPerWord = 8
@ -38,9 +33,6 @@ type Framebuffer struct {
vmem [VmemWords]word
readCount int
paletteChanged bool
shiftAssistData word
shiftAssistCount int
maskGenData word
}
func (f *Framebuffer) initialize() {
@ -61,11 +53,6 @@ func (f *Framebuffer) read(byteaddr word) (word, error) {
case FB_PS: result = f.paletteSlot
case FB_PD: result = f.readPalette()
case FB_CTL: result = f.readCtl()
case FB_SHIFTER: result = f.readShiftAssist()
case FB_SHIFTCOUNT: result = 0xFFFFFFF
case FB_SHIFTERM: result = f.readShifterM()
case FB_SHIFTERSP: result = f.readShifterSp()
case FB_MASKGEN: result = f.readMaskGen()
default:
}
return result, nil
@ -80,11 +67,6 @@ func (f *Framebuffer) write(value word, byteaddr word) (error) {
case FB_PS: f.paletteSlot = value
case FB_PD: f.writePalette(value)
case FB_CTL: f.writeCtl(value)
case FB_SHIFTER: f.writeShiftAssist(value)
case FB_SHIFTCOUNT: f.writeShiftCount(value)
case FB_SHIFTERM:
case FB_SHIFTERSP:
case FB_MASKGEN: f.writeMaskGen(value)
default:
}
@ -170,47 +152,3 @@ func (f *Framebuffer) readCtl() word {
func (f *Framebuffer) writeCtl(value word) {
}
func (f *Framebuffer) writeShiftAssist(value word) {
f.shiftAssistData = value
f.shiftAssistCount = 0
}
func (f *Framebuffer) readShiftAssist() word {
return f.shiftAssistData >> (f.shiftAssistCount * 4)
}
func (f *Framebuffer) writeShiftCount(value word) {
f.shiftAssistCount = int(value & 0x7)
}
func (f *Framebuffer) readShifterM() word {
return convertToMask(f.readShiftAssist())
}
func pixelToMask(pixels word, mask word) word {
if (pixels & mask) != 0 { return mask } else { return 0 }
}
func convertToMask(pixels word) word {
return pixelToMask(pixels, 0xF0000000) |
pixelToMask(pixels, 0x0F000000) |
pixelToMask(pixels, 0x00F00000) |
pixelToMask(pixels, 0x000F0000) |
pixelToMask(pixels, 0x0000F000) |
pixelToMask(pixels, 0x00000F00) |
pixelToMask(pixels, 0x000000F0) |
pixelToMask(pixels, 0x0000000F)
}
func (f *Framebuffer) readShifterSp() word {
return word(f.shiftAssistData << ((8-f.shiftAssistCount)*4))
}
func (f *Framebuffer) writeMaskGen(value word) {
f.maskGenData = value
}
func (f *Framebuffer) readMaskGen() word {
return convertToMask(f.maskGenData)
}

View file

@ -620,9 +620,6 @@ def create_image_with_stuff(imgfile):
slotnr = putfile("../examples/background.pict", None , f, part, partstart, slotnr)
slotnr = putfile("../examples/walking.sprt", None , f, part, partstart, slotnr)
slotnr = putfile("../examples/rocket.sprt", None , f, part, partstart, slotnr)
slotnr = putfile("../examples/sprite-testcard.sprt", None , f, part, partstart, slotnr)
slotnr = putfile("../examples/tiles.inc", None , f, part, partstart, slotnr)
slotnr = putfile("../examples/tiles.s", None , f, part, partstart, slotnr)
listdir(f, part)