mirror of
https://github.com/blondie7575/HiSprite.git
synced 2026-04-20 14:16:38 +00:00
Added support for the color white
This commit is contained in:
@@ -3,3 +3,5 @@ hgrtest.lst
|
||||
HGR.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate
|
||||
/.DS_Store
|
||||
/hisprite.lst
|
||||
/HiSprite.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate
|
||||
/HiSprite.xcodeproj/xcuserdata/qd.xcuserdatad/xcdebugger
|
||||
|
||||
+33
-14
@@ -3,7 +3,7 @@
|
||||
import sys,os,png
|
||||
|
||||
class Colors:
|
||||
black,magenta,green,orange,blue = range(5)
|
||||
black,magenta,green,orange,blue,white = range(6)
|
||||
|
||||
|
||||
|
||||
@@ -29,16 +29,19 @@ def main(argv):
|
||||
|
||||
disclaimer()
|
||||
|
||||
# Prologue
|
||||
print "%s: ;%d bytes per row" % (niceName,byteWidth)
|
||||
print "\tSAVE_AXY"
|
||||
print "\tldy PARAM0"
|
||||
print "\tldx MOD7_2,y"
|
||||
print "\tjmp (%s_JMP,x)\n" % (niceName)
|
||||
|
||||
# Bit-shift jump table
|
||||
print "%s_JMP:" % (niceName)
|
||||
for shift in range(0,7):
|
||||
print "\t.addr %s_SHIFT%d" % (niceName,shift)
|
||||
|
||||
# Blitting functions
|
||||
print "\n"
|
||||
for shift in range(0,7):
|
||||
print "%s_SHIFT%d:" % (niceName,shift)
|
||||
@@ -64,23 +67,30 @@ def layoutSpriteChunk(pixeldata,width,height,shift):
|
||||
byteWidth = width/2+1+1 # TODO: Calculate a power of two for this
|
||||
spriteChunks = [["" for y in range(height)] for x in range(byteWidth)]
|
||||
|
||||
# Layout rows
|
||||
for row in range(height):
|
||||
pixelRow = bitmap[row]
|
||||
bitStream = ""
|
||||
|
||||
# Compute raw bitstream for row from PNG pixels
|
||||
for pixelIndex in range(width):
|
||||
pixel = pixelColor(pixeldata,row,pixelIndex)
|
||||
if pixel == Colors.black:
|
||||
bitStream += "00"
|
||||
else:
|
||||
if pixel == Colors.green or pixel == Colors.orange:
|
||||
bitStream += "01"
|
||||
if pixel == Colors.white:
|
||||
bitStream += "11"
|
||||
else:
|
||||
bitStream += "10"
|
||||
|
||||
if pixel == Colors.green or pixel == Colors.orange:
|
||||
bitStream += "01"
|
||||
else:
|
||||
bitStream += "10"
|
||||
|
||||
# Shift bit stream as needed
|
||||
bitStream = shiftStringRight(bitStream,shift)
|
||||
bitStream = bitStream[:byteWidth*8]
|
||||
|
||||
|
||||
# Split bitstream into bytes
|
||||
bitPos = 0
|
||||
byteSplits = [0 for x in range(byteWidth)]
|
||||
|
||||
@@ -99,26 +109,33 @@ def layoutSpriteChunk(pixeldata,width,height,shift):
|
||||
bitChunk = bitStream[bitPos:bitPos+7]
|
||||
|
||||
bitChunk = bitChunk[::-1]
|
||||
|
||||
|
||||
# Set palette bit as needed. Note that we prefer high-bit white
|
||||
# because blue fringe is less noticeable than magenta
|
||||
highBit = "0"
|
||||
if pixel == Colors.orange or pixel == Colors.blue:
|
||||
if pixel == Colors.orange or pixel == Colors.blue or pixel == Colors.white:
|
||||
highBit = "1"
|
||||
|
||||
byteSplits[byteIndex] = highBit + bitChunk
|
||||
bitPos += 7
|
||||
|
||||
|
||||
# Generate blitting code
|
||||
for chunkIndex in range(len(byteSplits)):
|
||||
if (not byteSplits[chunkIndex].endswith("0000000")):
|
||||
|
||||
# Store byte into video memory
|
||||
if (not byteSplits[chunkIndex].endswith("0000000")): # Optimization- don't render all-black bytes
|
||||
spriteChunks[chunkIndex][row] = \
|
||||
"\tlda #%%%s\n" % byteSplits[chunkIndex] + \
|
||||
"\tora (SCRATCH0),y\n" + \
|
||||
"\tsta (SCRATCH0),y\n";
|
||||
|
||||
# Increment indices
|
||||
if chunkIndex == len(byteSplits)-1:
|
||||
spriteChunks[chunkIndex][row] += "\n"
|
||||
else:
|
||||
spriteChunks[chunkIndex][row] += "\tiny"
|
||||
|
||||
|
||||
# Finish the row
|
||||
if row<height-1:
|
||||
spriteChunks[chunkIndex][row] += "\tinx\n" + rowStartCalculatorCode();
|
||||
else:
|
||||
@@ -177,7 +194,9 @@ def pixelColor(pixeldata,row,col):
|
||||
else:
|
||||
if r==255 and g>0 and b==0:
|
||||
color = Colors.orange
|
||||
|
||||
else:
|
||||
if r==255 and g==255 and b==255:
|
||||
color = Colors.white
|
||||
return color
|
||||
|
||||
|
||||
@@ -204,7 +223,7 @@ PNG file must not have an alpha channel!
|
||||
|
||||
def disclaimer():
|
||||
print '''
|
||||
; This file was generated by SpriteGenerator.py, a sprite generation tool by Quinn Dunki.
|
||||
; This file was generated by HiSprite.py, a sprite compiler by Quinn Dunki.
|
||||
; If you feel the need to modify this file, you are probably doing it wrong.
|
||||
'''
|
||||
return
|
||||
@@ -212,4 +231,4 @@ def disclaimer():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
701B5E151D84823300E6D330 /* spritegen2.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = spritegen2.s; sourceTree = "<group>"; };
|
||||
701B5E161D84823300E6D330 /* spritegen3.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = spritegen3.s; sourceTree = "<group>"; };
|
||||
701B5E171D84824400E6D330 /* hgrtableY.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = hgrtableY.s; sourceTree = "<group>"; };
|
||||
701B5E181D849F3800E6D330 /* graphics.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = graphics.s; sourceTree = "<group>"; };
|
||||
70A65D491E0B137D00FB9D02 /* spritegen4.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = spritegen4.s; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
@@ -27,12 +29,14 @@
|
||||
701B5E111D84817500E6D330 /* HiSprite.py */,
|
||||
701B5E0E1D84810000E6D330 /* macros.s */,
|
||||
701B5E101D84813500E6D330 /* hisprite.s */,
|
||||
701B5E181D849F3800E6D330 /* graphics.s */,
|
||||
701B5E121D8481C800E6D330 /* hgrtableX.s */,
|
||||
701B5E171D84824400E6D330 /* hgrtableY.s */,
|
||||
701B5E131D84820100E6D330 /* spritegen0.s */,
|
||||
701B5E141D84823300E6D330 /* spritegen1.s */,
|
||||
701B5E151D84823300E6D330 /* spritegen2.s */,
|
||||
701B5E161D84823300E6D330 /* spritegen3.s */,
|
||||
70A65D491E0B137D00FB9D02 /* spritegen4.s */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
||||
Generated
BIN
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
Binary file not shown.
|
After Width: | Height: | Size: 204 B |
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
+205
@@ -0,0 +1,205 @@
|
||||
;
|
||||
; graphics.s
|
||||
;
|
||||
; Created by Quinn Dunki on 9/10/16
|
||||
; Copyright (c) 2015 One Girl, One Laptop Productions. All rights reserved.
|
||||
;
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; EnableHires
|
||||
; Trashes A
|
||||
;
|
||||
EnableHires:
|
||||
lda TEXT
|
||||
lda HIRES1
|
||||
lda HIRES2
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; SaveBackground
|
||||
; PARAM0: X pos
|
||||
; PARAM1: Y pos
|
||||
; PARAM2: Storage area (LSB)
|
||||
; PARAM3: Storage area (MSB)
|
||||
;
|
||||
; Assumes 6-byte-wide, 8px-high sprites
|
||||
;
|
||||
SaveBackground:
|
||||
SAVE_AXY
|
||||
ldy #0
|
||||
lda #0
|
||||
pha
|
||||
|
||||
saveBackground_loop:
|
||||
clc
|
||||
pla
|
||||
pha
|
||||
adc PARAM1 ; Calculate Y line
|
||||
tax
|
||||
|
||||
lda HGRROWS_H,x ; Compute hires row
|
||||
sta saveBackground_smc0+2
|
||||
sta saveBackground_smc1+2
|
||||
sta saveBackground_smc2+2
|
||||
sta saveBackground_smc3+2
|
||||
lda HGRROWS_L,x
|
||||
sta saveBackground_smc0+1
|
||||
sta saveBackground_smc1+1
|
||||
sta saveBackground_smc2+1
|
||||
sta saveBackground_smc3+1
|
||||
|
||||
ldx PARAM0 ; Compute hires column
|
||||
lda DIV7_2,x
|
||||
tax
|
||||
|
||||
saveBackground_smc0:
|
||||
lda $2000,x
|
||||
sta (PARAM2),y
|
||||
iny
|
||||
inx
|
||||
saveBackground_smc1:
|
||||
lda $2000,x
|
||||
sta (PARAM2),y
|
||||
iny
|
||||
inx
|
||||
saveBackground_smc2:
|
||||
lda $2000,x
|
||||
sta (PARAM2),y
|
||||
iny
|
||||
inx
|
||||
saveBackground_smc3:
|
||||
lda $2000,x
|
||||
sta (PARAM2),y
|
||||
iny
|
||||
|
||||
pla
|
||||
inc
|
||||
pha
|
||||
|
||||
cpy #48
|
||||
bne saveBackground_loop
|
||||
|
||||
pla
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; RestoreBackground
|
||||
; PARAM0: X pos
|
||||
; PARAM1: Y pos
|
||||
; PARAM2: Storage area (LSB)
|
||||
; PARAM3: Storage area (MSB)
|
||||
;
|
||||
; Assumes 4-byte-wide, 8px-high sprites
|
||||
;
|
||||
RestoreBackground:
|
||||
SAVE_AXY
|
||||
ldy #0
|
||||
lda #0
|
||||
pha
|
||||
|
||||
restoreBackground_loop:
|
||||
clc
|
||||
pla
|
||||
pha
|
||||
adc PARAM1 ; Calculate Y line
|
||||
tax
|
||||
|
||||
lda HGRROWS_H,x ; Compute hires row
|
||||
sta restoreBackground_smc0+2
|
||||
sta restoreBackground_smc1+2
|
||||
sta restoreBackground_smc2+2
|
||||
sta restoreBackground_smc3+2
|
||||
lda HGRROWS_L,x
|
||||
sta restoreBackground_smc0+1
|
||||
sta restoreBackground_smc1+1
|
||||
sta restoreBackground_smc2+1
|
||||
sta restoreBackground_smc3+1
|
||||
|
||||
ldx PARAM0 ; Compute hires column
|
||||
lda DIV7_2,x
|
||||
tax
|
||||
|
||||
lda (PARAM2),y
|
||||
restoreBackground_smc0:
|
||||
sta $2000,x
|
||||
iny
|
||||
inx
|
||||
|
||||
lda (PARAM2),y
|
||||
restoreBackground_smc1:
|
||||
sta $2000,x
|
||||
iny
|
||||
inx
|
||||
|
||||
lda (PARAM2),y
|
||||
restoreBackground_smc2:
|
||||
sta $2000,x
|
||||
iny
|
||||
inx
|
||||
|
||||
lda (PARAM2),y
|
||||
restoreBackground_smc3:
|
||||
sta $2000,x
|
||||
iny
|
||||
|
||||
pla
|
||||
inc
|
||||
pha
|
||||
|
||||
cpy #48
|
||||
bne restoreBackground_loop
|
||||
|
||||
pla
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; LinearFill
|
||||
; A: Byte value to fill
|
||||
; Trashes all registers
|
||||
;
|
||||
LinearFill:
|
||||
ldx #0
|
||||
|
||||
linearFill_outer:
|
||||
pha
|
||||
lda HGRROWS_H,x
|
||||
sta linearFill_inner+2
|
||||
lda HGRROWS_L,x
|
||||
sta linearFill_inner+1
|
||||
pla
|
||||
|
||||
ldy #39
|
||||
linearFill_inner:
|
||||
sta $2000,y
|
||||
dey
|
||||
bpl linearFill_inner
|
||||
|
||||
inx
|
||||
cpx #192
|
||||
bne linearFill_outer
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; VenetianFill
|
||||
; A: Byte value to fill
|
||||
; Trashes all registers
|
||||
;
|
||||
VenetianFill:
|
||||
ldx #$3f
|
||||
venetianFill_outer:
|
||||
stx venetianFill_inner+2
|
||||
ldy #$00
|
||||
venetianFill_inner:
|
||||
sta $2000,y ; Upper byte of address is self-modified
|
||||
iny
|
||||
bne venetianFill_inner
|
||||
dex
|
||||
cpx #$1f
|
||||
bne venetianFill_outer
|
||||
rts
|
||||
|
||||
Binary file not shown.
+80
-72
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; hgrtest.s
|
||||
; hisprite.s
|
||||
;
|
||||
; Created by Quinn Dunki on 7/19/16
|
||||
; Copyright (c) 2015 One Girl, One Laptop Productions. All rights reserved.
|
||||
@@ -65,98 +65,106 @@ main:
|
||||
jsr EnableHires
|
||||
|
||||
lda #$00
|
||||
jsr LinearFill
|
||||
jsr VenetianFill
|
||||
|
||||
ldx #0
|
||||
;;;;
|
||||
stz PARAM0
|
||||
stz PARAM1
|
||||
jsr BOXW_MAG
|
||||
|
||||
lda #10
|
||||
sta PARAM1
|
||||
jsr BOXW_MIX
|
||||
|
||||
lda #20
|
||||
sta PARAM1
|
||||
jsr BOXW_ORG
|
||||
|
||||
rts
|
||||
;;;;
|
||||
|
||||
loop:
|
||||
txa
|
||||
asl
|
||||
asl
|
||||
sta PARAM0
|
||||
lda #0
|
||||
sta PARAM1
|
||||
jsr BOX_MAG
|
||||
|
||||
lda #88
|
||||
sta PARAM1
|
||||
jsr BOX_GRN
|
||||
lda #<bgBuffer
|
||||
sta PARAM2
|
||||
lda #>bgBuffer
|
||||
sta PARAM3
|
||||
jsr SaveBackground
|
||||
|
||||
lda #96
|
||||
sta PARAM1
|
||||
jsr BOX_ORG
|
||||
jsr BOXW_MAG
|
||||
lda #$80
|
||||
jsr ROMWAIT
|
||||
|
||||
lda #184
|
||||
sta PARAM1
|
||||
jsr BOX_BLU
|
||||
jsr RestoreBackground
|
||||
|
||||
inx
|
||||
cpx #35
|
||||
bne loop
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; EnableHires
|
||||
; Trashes A
|
||||
;
|
||||
EnableHires:
|
||||
lda TEXT
|
||||
lda HIRES1
|
||||
lda HIRES2
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; LinearFill
|
||||
; A: Byte value to fill
|
||||
; Trashes all registers
|
||||
;
|
||||
LinearFill:
|
||||
ldx #0
|
||||
|
||||
linearFill_outer:
|
||||
pha
|
||||
lda HGRROWS_H,x
|
||||
sta linearFill_inner+2
|
||||
lda HGRROWS_L,x
|
||||
sta linearFill_inner+1
|
||||
pla
|
||||
|
||||
ldy #39
|
||||
linearFill_inner:
|
||||
sta $2000,y
|
||||
dey
|
||||
bpl linearFill_inner
|
||||
|
||||
inx
|
||||
cpx #192
|
||||
bne linearFill_outer
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; VenetianFill
|
||||
; A: Byte value to fill
|
||||
; Trashes all registers
|
||||
;
|
||||
VenetianFill:
|
||||
ldx #$3f
|
||||
venetianFill_outer:
|
||||
stx venetianFill_inner+2
|
||||
ldy #$00
|
||||
venetianFill_inner:
|
||||
sta $2000,y ; Upper byte of address is self-modified
|
||||
iny
|
||||
bne venetianFill_inner
|
||||
dex
|
||||
cpx #$1f
|
||||
bne venetianFill_outer
|
||||
cpx #133
|
||||
; bne loop
|
||||
rts
|
||||
|
||||
bgBuffer:
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
|
||||
.include "graphics.s"
|
||||
.include "hgrtableX.s"
|
||||
.include "hgrtableY.s"
|
||||
.include "spritegen0.s"
|
||||
.include "spritegen1.s"
|
||||
.include "spritegen2.s"
|
||||
.include "spritegen3.s"
|
||||
.include "spritegen4.s"
|
||||
|
||||
; Suppress some linker warnings - Must be the last thing in the file
|
||||
.SEGMENT "ZPSAVE"
|
||||
|
||||
+948
-686
File diff suppressed because it is too large
Load Diff
+495
-233
File diff suppressed because it is too large
Load Diff
+1408
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user