I figured out more of the text format, there is escape characters(0b11110) where the next 13bits are a pointer. The pointer(whos base I discovered at 0b1110000000000, and so can scale it to match the table I generated of plain text). The keywords all evenly break on 8 bytes so after I figured out what that pointer actually meant it wasn't bad to grab the list, what I mean is stuff like this:
Basically you extract the word, which is terminated by a 0b11111, then insert that into the bitstream you are already processing at 5 bits per character and run through it like normal. There are a couple details I still have to figure, because ~20 of the entries are skipped and do not get counted(which makes me consider it is actually a counting scanning routine to find it..) so all words after an index gets off by 1..then it happens again so 2..though it could actually be my code screwing up but it definitely brought many new sentences out so far.
I dabbled with actually laying some cycles out for some kind of SPI bitmapped mode related to my previous post. As far as I can see it works fine without a linebuffer and could build up a buffer for next line even if it was a 240 pixel wide bitmap instead of the 112. If someone with more experience would take the time to do a sanity check on it I would appreciate it before I invest too much time. I believe it shows that we could draw exactly like the NES does backgrounds(using a large repeating pallet for speed). The problem is the NES has 2 planes, the BG and the sprites, where the BG follows the limits of this videomode exactly, but the sprites have their own pallet(0 is transparent, so really it is only 3 colors they can introduce into something). I have to think about it, but with a yet bigger pallet(using 2k to have a 3 bit attribute, and then clever sprite drawing that takes care to alter the attribute of any 16x16 pixel slice it blits too), that might work. That is pretty abstract in my head right now and I'd have to think if that is really true. If someone can shoot my code down right now they will save me the trouble
Code: Select all
render_bitmap_then_tile_line:
; Begin drawing the 112 pixels wide bitmap, the SPI ram is ready to read
; YH is already setup for the upper 2 pallet bits for pixels 0-15 2 bit "attribute"
; Y is pointed at the color pallet, where each color is repeated 64 time
; this allows the upper 2 bits of YL to select 1 of 4 possible colors
; every 16 pixels YH can point to 16 colors new colors, so 4 different colors
; out of a possible 16 for each 16 pixel slice.
;
; pallet format:(YH can choose between 4 sets of these, so the pallet takes 64*4*4=1024 bytes of 644 ram
; this lets the upper 2 bits of YL choose a color
; c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,//color 0
; c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,c0,
;
; c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,//color 1
; c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,
;
; c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,//color 2
; c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,c2,
;
; c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,//color 3
; c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,c3,
;
; do HSYNC and setup stuff, in the real mode we should actually start out
; ahead. this is for illustration to see how much ahead we could be for
; the next line. We could probably gain quite a bit during the right side
; tile section as well...etc.
in YL,_SFR_IO_ADDR(SPDR); read the SPI byte comprising of 4x2bit values(pixels 0,1,2,3)
out _SFR_IO_ADDR(SPDR),25; queue up the next SPI read(18 cycles)
ld r16,Y; get color for pixel 0(upper 2 bits of YL selects color)
lsr YL; prepare for pixel 1(start getting pixel 1 into the upper 2 bits)
out _SFR_IO_ADDR(DATA_PORT),r16; output the pixel color we just read(pixel 0)
lsr YL; prepare for pixel 1
ld r16,Y; get color value for pixel 1
lsr YL; prepare for pixel 2
lsr YL; prepare for pixel 2
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 1
ld r16,Y; get color for pixel 2
lsr YL; prepare for pixel 3
lsr YL; prepare for pixel 3
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 2
in r20,_SFR_IO_ADDR(SPDR); save SPI byte for pixels 4,5,6,7(pixel 3 is still in YL)
out _SFR_IO_ADDR(SPDR),25; queue next read(18 cycles)
ld r16,Y; get color for pixel 3(now we can overwrite it)
mov YL,r20; set up for pixels 4,5,6,7
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 3
ld r17,Y; get color for pixel 4(upper 2 bits are already there)
lsr YL; prepare for pixel 5
lsr YL; prepare for pixel 5
nop
out _SFR_IO_ADDR(DATA_PORT),r17; draw pixel 4
ld r16,Y; get color for pixel 5
lsr YL; prepare for pixel 6
lsr YL; prepare for pixel 6
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 5
in r20; save SPI byte for pixels 8,9,10,11
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
ld r16,Y; get color for pixel 6
lsr YL; prepare for pixel 7
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 6
lsr YL; prepare for pixel 7
ld YL; get color for pixel 7
mov YL,r20; set up for pixels 8,9,10,11
lsr YL; prepare for pixel 8
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 7
lsr YL; prepare for pixel 8
ld YL; get color for pixel 8
lsr YL; prepare for pixel 9
lsr YL; prepare for pixel 9
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 8
in r20,_SFR_IO_ADDR(SPDR); save SPI byte for pixels 12,13,14,15
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
ld YL; get color for pixel 9
lsr YL; prepare for pixel 10
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 9
lsr YL; prepare for pixel 10
ld r16,Y; get color for pixel 10
lsr YL; prepare for pixel 11
lsr YL; prepare for pixel 11
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 10
ld r16,Y; get color for pixel 11
mov YL,r20; set up for pixels 12,13,14,15
ld r16,Y; get color for pixel 12
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 11
in r20,_SFR_IO_ADDR(SPDR); save SPI byte for pixels 16,17,18,19
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
lsr YL; prepare for pixel 13
lsr YL; prepare for pixel 13
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 12
ld r16,Y; get color for pixel 13
lsr YL; prepare for pixel 14
lsr YL; prepare for pixel 14
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 13
ld r16,Y; get color for pixel 14
lsr YL; prepare for pixel 15
lsr YL; prepare for pixel 15
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 14
in r21,_SFR_IO_ADDR(SPDR); save SPI byte for pixels 20,21,22,23
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
ld r16,YL; get color for pixel 15
mov YL,r20; set up for pixels 16,17,18,19
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 15
pop YH; get precalculated base for next "attribute"
ld r16,Y; get color for pixel 16
lsr YL; prepare for pixel 17
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 16
lsr YL; prepare for pixel 17
ld r16,Y; get color for pixel 17
lsr YL; prepare for pixel 18
lsr YL; prepare for pixel 18
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 17
in r20,_SFR_IO_ADDR(SPDR); save SPI byte for pixels 24,25,26,27
out _SFR_IO_ADDR(SPDR),25; queue next SPI read
ld r16; get color for pixel 18
lsr YL; prepare for pixel 19
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 18
lsr YL; prepare for pixel 19
ld r16,Y; get color for pixel 19
mov YL,r21; set up for pixels 20,21,22,23
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 19
ld r16,Y; get color for pixel 20
lsr YL; prepare for pixel 21
lsr YL; prepare for pixel 21
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 20
in r21,_SFR_IO_ADDR(SPDR); save pixels 28,29,30,31 for later
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles later)
ld r16,Y; get color for pixel 21
lsr YL; prepare for pixel 22
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 21
lsr YL; prepare for pixel 22
ld r16,Y; get color for pixel 22
lsr YL; prepare for pixel 23
lsr YL; prepare for pixel 23
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 22
ld r16,Y; get color for pixel 23
mov YL,r20; set up for pixels 24,25,26,27
ld r16,Y; get color for pixel 24
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 23
in r20,_SFR_IO_ADDR(SPDR); save pixels 32,33,34,35 for later
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
lsr YL; prepare for pixel 25
lsr YL; prepare for pixel 25
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 24
ld r16,Y; get color for pixel 25
lsr YL; prepare for pixel 26
lsr YL; prepare for pixel 26
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 25
ld r16,Y; get color for pixel 26
lsr YL; prepare for pixel 27
lsr YL; prepare for pixel 27
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 26
in r21,_SFR_IO_ADDR(SPDR); save pixels 36,37,38,39 for later
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles later)
ld r17,Y; get color for pixel 27
mov YL,r20; set up for pixels 28,29,30,31
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 27
ld r16,Y; get color for pixel 28
lsr YL; prepare for pixel 29
lsr YL; prepare for pixel 29
nop
out _SFR_IO_ADDR(DATA_PORT),r17; draw pixel 28
ld r16,Y; get color for pixel 29
lsr YL; prepare for pixel 30
lsr YL; prepare for pixel 30
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 29
in r20,_SFR_IO_ADDR(SPDR); save pixels 40,41,42,43 for later
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
ld r16,Y; get color for pixel 30
lsr YL; prepare for pixel 31
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 30
lsr YL; prepare for pixel 31
ld r16,Y; get color for pixel 31
mov YL,r21; set up for pixels 32,33,34,35
nop
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 31
pop YH; get precalculated base for next "attribute"
ld r17,YL; get color for pixel 32
lsr YL; prepare for pixel 33
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 32
in r20,_SFR_IO_ADDR(SPDR); save pixels 44,45,46,47 for later
out _SFR_IO_ADDR(SPDR),25; queue next SPI read(18 cycles)
lsr YL; prepare for pixel 33
ld r16,Y; get color for pixel 33
out _SFR_IO_ADDR(DATA_PORT),r16; draw pixel 33
//etc up to 240 pixels
edit-r20 and r21 I might be corrupting towards the end where you might have to juggle in more registers to keep getting ahead. It's more a proof of concept that you start accumulating bytes pretty quickly, for whatever use that is. The attributes I'm popping off the stack, there is easily time to pull them off the SPI as bits(4 16pixel slices per byte), convert them to a real pointer base, and push them while you wait for the next during the checkerboard output.