diff --git a/Async.inc b/Async.inc index bd51d43..65ec4a3 100644 --- a/Async.inc +++ b/Async.inc @@ -17,8 +17,8 @@ def ASYNC_STACK_TOP equ $ffc0 def ASYNC_THREAD_CALL equ ASYNC_STACK_TOP - 2 - 2 ; timing for async execution, in scanlines -def SAFE_ASYNC_START EQU 148 -def SAFE_ASYNC_END EQU 153 +def SAFE_ASYNC_START EQU 146 +def SAFE_ASYNC_END EQU 0 Async_Spawn_HL: di diff --git a/Audio.inc b/Audio.inc index 849e369..8e9e866 100644 --- a/Audio.inc +++ b/Audio.inc @@ -4,7 +4,6 @@ SoundSetup: ld [rROMB0], a ld de, gb_tarot_theme - ld c, BANK(gb_tarot_theme) call AudioEngineInit ; Play song ld a, [cvCardBank] @@ -12,7 +11,10 @@ SoundSetup: ret SoundUpdate: - call AudioEngineUpdate + ld a, BANK(AudioEngineUpdate) + ld [rROMB0], a + + ;call AudioEngineUpdate ld a, [cvCardBank] ld [rROMB0], a @@ -62,7 +64,7 @@ channel_vars 3 channel_3_loaded_instrument: db channel_vars 4 -SECTION "Audio Engine", ROM0 +SECTION "Audio Engine", ROMX Periods: DW 44, 156, 262, 363, 457, 547, 631, 710, 786, 854, 923, 986 @@ -120,7 +122,7 @@ AudioEngineInit: AudioEngineUpdate: ld a, [ordersBank] - ld [rROMB0], a + ;ld [rROMB0], a call IncrementTick ld a, [tick] @@ -626,4 +628,5 @@ UpdateRegisters4: ld a, 0 ld [channel_4_trigger], a ret - ret \ No newline at end of file + +INCLUDE "theme.inc" diff --git a/CardHelpers.inc b/CardHelpers.inc index 6fc42a8..7ad46e5 100644 --- a/CardHelpers.inc +++ b/CardHelpers.inc @@ -4,6 +4,69 @@ cvCardBank: db cvCardAddress: dw POPS +FindCardTileMap: ; puts the tilemap into hl + ld hl, cvCardAddress + ld c, [hl] + inc hl + ld b, [hl] + ld l, c + ld h, b + ld bc, Card_Offset_tilemap + add hl, bc ; address of the length and address of the tilemap + + inc hl + inc hl ; step past the two-byte length of the tilemap + + ld c, [hl] + inc hl + ld b, [hl] + + ld h, b + ld l, c + + ret +FindCardKeyTiles: + ld hl, cvCardAddress + ld c, [hl] + inc hl + ld b, [hl] + ld l, c + ld h, b + ld bc, Card_Offset_keytiles + add hl, bc ; address of the length and address of the key tilels + + inc hl + inc hl ; step past the two-byte length of the key tiles + + ld c, [hl] + inc hl + ld b, [hl] + + ld h, b + ld l, c + + ret +FindCardSpriteTiles: + ld hl, cvCardAddress + ld c, [hl] + inc hl + ld b, [hl] + ld l, c + ld h, b + ld bc, Card_Offset_spritetiles + add hl, bc ; address of the length and address of the sprite tile data + + inc hl + inc hl ; step past the two-byte length of the sprite tile data + + ld c, [hl] + inc hl + ld b, [hl] + + ld h, b + ld l, c + ret + LoadCardData: LoadCardDataAsync: ; first and foremost, clear the card init, update, and draw handles, so there's diff --git a/GraphicsManipulation.inc b/GraphicsManipulation.inc new file mode 100644 index 0000000..640e71d --- /dev/null +++ b/GraphicsManipulation.inc @@ -0,0 +1,209 @@ + +GetDoubledBottomNibble: + push bc + swap b + jp GetDoubledNibbleInner +GetDoubledTopNibble: + push bc + jp GetDoubledNibbleInner +GetDoubledNibbleInner: + ; b holds a byte of tile data + ; this returns the first byte of the doubled tile data + ld a, b + and a, %10000000 ; a contains a0000000 + ld c, a + srl c + or a, c ; a now contains aa000000 + ld [vBuildingByte], a ; vBuildingByte has aa000000 + ld a, b + and a, %01000000 ; a has 0b000000 + srl a ; a has 00b00000 + ld c, a + srl c ; c has 000b0000 + or a, c + ld c, a ; c has 00bb0000 + ld a, [vBuildingByte] + or a, c + ld [vBuildingByte], a ; vBuildingBye has aabb0000 + ld a, b + and a, %00100000 ; 00c00000 + srl a ; 000c0000 + srl a ; 0000c000 + ld c, a + srl c ; 00000c00 + or a, c + ld c, a + ld a, [vBuildingByte] + or a, c + ld [vBuildingByte], a ; vBuildingByte has aabbcc00 + ld a, b + and a, %00010000 + srl a + srl a + srl a + ld c, a + srl c + or a, c + ld c, a + ld a, [vBuildingByte] + or a, c + ld [vBuildingByte], a ; vBuilldingByte now has aabbccdd! + pop bc + ret ;so does a. + +WriteBottomHalfDoubledTile: +; this draws the bottom half of a tile pointed at by hl into [de] + ld bc, 8 + add hl, bc +WriteTopHalfDoubledTile: +; this draws the top half of a tile into [de] +; both of these functions take hl, pointing to tile data, and write four +; lines of it, doubled, to DE +; in other words we draw the left half of the top of a tile into [de] +; then we draw the right half of the top of a tile into [de] +; ending with writing 32 bytes to [de], or two tiles' worth. + push hl + call DoubleLeftSideOfLineOfTile + call DoubleLeftSideOfLineOfTile + call DoubleLeftSideOfLineOfTile + call DoubleLeftSideOfLineOfTile + + pop hl + call DoubleRightSideOfLineOfTile + call DoubleRightSideOfLineOfTile + call DoubleRightSideOfLineOfTile + call DoubleRightSideOfLineOfTile + + ld bc, 8 + add hl, bc + ret + +DoubleLeftSideOfLineOfTile: + ; hl points to tile data. + ; de points to a buffer we want to write into + ; this will increment hl twice to point at the next line + ; and de four times, writing the doubled left side + ld b, [hl] + call GetDoubledTopNibble + ld [de], a ; write that to a + inc hl ; now we're poinitinig at the second bitplane. + inc de + ld b, [hl] + call GetDoubledTopNibble + ld [de], a ; write that to a + + ; now we want to double that line. so fetch the two bytes we just wrote + ; and write them again. + dec de + ld a, [de] + inc de + inc de + ld [de], a + dec de + ld a, [de] + inc de + inc de + ld [de], a + + inc de + inc hl + + ret +DoubleRightSideOfLineOfTile: + ; hl points to tile data. + ; de points to a buffer we want to write into + ; this will increment hl twice to point at the next line + ; and de four times, writing the doubled left side + ld b, [hl] + call GetDoubledBottomNibble + ld [de], a ; write that to a + inc hl ; now we're poinitinig at the second bitplane. + inc de + ld b, [hl] + call GetDoubledBottomNibble + ld [de], a ; write that to a + + ; now we want to double that line. so fetch the two bytes we just wrote + ; and write them again. + dec de + ld a, [de] + inc de + inc de + ld [de], a + dec de + ld a, [de] + inc de + inc de + ld [de], a + + inc de + inc hl + + ret + + + +DrawByte: ; accepts [hl] as the number to write, de as location to write tile IDs to +; writes tile IDs for one byte (two nibbles) from [hl] into [de] + ld b, 0 + + push hl + ld a, [hl] + swap a + and a, $0F + ld c, a + ld hl, .lowerHex + add hl, bc + ld a, [hl] + ld [de], a + inc de + + pop hl + ld a, [hl] + and a, $0F + ld c, a + ld hl, .lowerHex + add hl, bc + ld a, [hl] + ld [de], a + + ret + +.hex ; tile IDs for hex values. this can live elsewhere alongside WriteByte + ; 0, 1, 2, 3, + db $a0, $a1, $a2, $a3 + ; 4, 5, 6, 7, + db $a4, $a5, $a6, $a7 + ; 8, 9 + db $a8, $a9 + ; a, b, c, d, e, f + db $b1, $b2, $b3, $b4, $b5, $b6 +.lowerHex ; tile IDs for hex values. this can live elsewhere alongside WriteByte + ; 0, 1, 2, 3, + db $a0, $a1, $a2, $a3 + ; 4, 5, 6, 7, + db $a4, $a5, $a6, $a7 + ; 8, 9 + db $a8, $a9 + ; a, b, c, d, e, f + db $d1, $d2, $d3, $d4, $d5, $d6 + + + +FindTileData: ; give it a=index into some tiles, hl=what to start from + ; returns hl = start of thatt tile data + ld b, h + ld c, l + + ld h, 0 + ld l, a + add hl, hl ; hl * 2 + add hl, hl ; hl * 4 + add hl, hl ; hl * 8 + add hl, hl ; hl * 16 + + add hl, bc + + ret + + \ No newline at end of file diff --git a/Printing.inc b/Printing.inc new file mode 100644 index 0000000..6bac91b --- /dev/null +++ b/Printing.inc @@ -0,0 +1,757 @@ +PUSHS "Printer Variables", WRAM0[PRINTER_VARS_START] +vTooBusyForPrinter: db ; one if we're too busy to use the async thread for printer stuff +vPrinterState: db ; options: NONE, READY, ERROR, FULL, PRINTING +def PS_NONE equ 0 +def PS_READY equ 1 +def PS_ERROR equ 2 +def PS_FULL equ 3 +def PS_PRINTING equ 4 +vPrinterReturnValue: dw +vPrinterReturnValuePrevious: dw +vPrinterReturnValueChanged: db +vBuildingByte: dw +vPrinterIsReady: db + +vPrinterRow: db +vPrinterStart: db +POPS + +CheckForPrinter: + ld a, $F + ld hl, ZEROES + ld bc, 0 + call SendPacket + ret + +UpdatePrintUI: + ld a, [vPrinterState] + + cp a, PS_NONE + ld hl, BanishPrinterUI + jp z, Async_Spawn_HL + + cp a, PS_READY + ld hl, SummonPrinterUI + jp z, Async_Spawn_HL + + cp a, PS_ERROR + ld hl, ShowErrorUI + jp z, Async_Spawn_HL + + cp a, PS_PRINTING + ld hl, ShowPrinting + jp z, Async_Spawn_HL + + cp a, PS_FULL + ld hl, ShowFull + jp z, Async_Spawn_HL + + ld hl, BanishPrinterUI + jp Async_Spawn_HL + +UpdatePrintUIImmediate: + ld a, [vPrinterReturnValue] + cp a, $81 + call z, SummonPrinterUI + + ld a, [vPrinterReturnValue] + cp a, $81 + call nz, BanishPrinterUI + ret + +BanishPrinterUI: + ld hl, PrinterNotDetected + ld de, _SCRN0 + 32*1 + 17 + ld b, 2 + ld c, 2 + call CopyTilesToMap + ret +ShowErrorUI: + ld hl, PrinterError + ld de, _SCRN0 + 32*1 + 17 + ld b, 2 + ld c, 2 + call CopyTilesToMap + ret +ShowPrinting: + ld hl, PrinterPrinting + ld de, _SCRN0 + 32*1 + 17 + ld b, 2 + ld c, 2 + call CopyTilesToMap + ret +ShowFull: + ld hl, PrinterFull + ld de, _SCRN0 + 32*1 + 17 + ld b, 2 + ld c, 2 + call CopyTilesToMap + ret +SummonPrinterUI: + ld hl, PrinterAvailable + ld de, _SCRN0 + 32*1 + 17 + ld b, 2 + ld c, 2 + call CopyTilesToMap + ret + + +SendPacket: + ; a should be the command byte + ; hl shoulld point at data to send + ; bc should be the length of data + ; squashes de for the checksum. + push af + + ld a, $88 + call SendByte + ld a, $33 + call SendByte + pop af + ld d, 0 + ld e, a ; the checksum always starts with a vallue of whatever the command is + call SendByte + ld a, $00 + call SendByte + ld a, c + call SendByte + ld a, b + call SendByte + + ld a, e + add a, b + ld e, a + ld a, d + adc a, 0 + ld d, a + + ld a, e + add a, c + ld e, a + ld a, d + adc a, 0 + ld d, a + + ld a, b + or a, c + jp z, .doneWithByteLoop +.byteLoop + ld a, [hl] + add a, e + ld e, a + ld a, d + adc a, 0 + ld d, a + + ld a, [hl+] + call SendByte + dec bc + ld a, b + or a, c + jp nz, .byteLoop +.doneWithByteLoop + + ld a, e + call SendByte + + ld a, d + call SendByte + + ld a, $00 + call SendByte + ld [vPrinterReturnValue], a + + ld a, $00 + call SendByte + ld [vPrinterReturnValue+1], a + + call UpdatePrinterStatus + ret + +UpdatePrinterStatus: +;vPrinterState: db ; options: NONE, READY, ERROR, FULL, PRINTING + ld a, PS_NONE + ld [vPrinterState], a + ld a, [vPrinterReturnValue] + cp a, $81 + ret nz ; if the alive byte isn't $81, return with PS_NONE + + ld a, PS_ERROR + ld [vPrinterState], a + ld a, [vPrinterReturnValue+1] + and a, $F0 + ret nz ; if the top nibble is non-zero, there's some error + + ld a, PS_FULL + ld [vPrinterState], a + ld a, [vPrinterReturnValue+1] + bit 2, a + ret nz ; if the FULL bit iis set then it's full\ + + ld a, PS_PRINTING + ld [vPrinterState], a + ld a, [vPrinterReturnValue+1] + bit 1, a + ret nz ; if the printing bit is set then it's printing + + ld a, PS_READY + ld [vPrinterState], a + ret ; if we didn't find any of the bits we check for, it's good to go + + +PrepNetwork: + ld a, 0 + ld [vPrinterStart], a + + ld a, $1 + ld [rSC], a + ret + +SendByte: +; waits until the thing is free, then sends the byte in a. puts the receiived +; byte in a anad returns. + push af + + .waitForFree + ld a, [rSC] + bit 7, a + jp nz, .waitForFree + + pop af + ld [rSB], a + + ld a, 0 + set 7, a ; request transfer + set 0, a ; set to leader + ld [rSC], a + + .waitForResponse + ld a, [rSC] + bit 7, a + jp nz, .waitForResponse + + ld a, [rSB] + ret + +KickOffPrintJob: + ld a, 1 + ld [vBlocked], a + + ld a, 1 + ld [vPrinterStart],a + ld a, 0 + ld [vPrinterRow], a + + ret + +RunPrintJob: + ld a, [vPrinterStart] + cp a, 0 + ret z + + ld a, [vPrinterRow] + bit 0, a + jp z, WaitForPrintable + + cp a, 1 + jp nz, :+ + call PlanTopRow + call BuildTopRow + call DoubleTheBuffer + call PrintTheBuffer + ld a, [vPrinterRow] + inc a + ld [vPrinterRow], a + ret + : + cp a, 35 + jp z, DoBottomRow + cp a, 37 + jp z, FinishUp + + call PlanRowA + call BuildTopRow + + ld b, 8 ; pre-increment so that when we pre-decrement in the loop later it works + sla a + sla a + sla a ; mullitply by 8 + add a, 24 ; offset for the border and overscan + add a, b ; start from the bottom row of these tiles, a*8 + 7 + .addSpriteLinesLoop + dec a + + ld [vCurrentScanline], a + call AddSpritesToLine + + dec b + jp nz, .addSpriteLinesLoop + .doneAddSpriteLinesLoop + + call DoubleTheBuffer + call PrintTheBuffer + ld a, [vPrinterRow] + inc a + ld [vPrinterRow], a + ret + +PlanTopRow: + ; draw the top of a card as tile ids in buffer one + ld hl, CardBrowse.UITilemap + ld bc, 10 + ld de, BUFFER_ONE + call CopyRange ; copy tiles for the top row to the first buffer + ld b, b + ret +PlanRowA: + srl a ; divide by two and subtract one to get row numbre in card space + dec a + push af + + ld de, BUFFER_ONE + + ld a, $0b + ld [de], a + inc de + + pop af + push af + + call FindCardTileMap ; now hl points at the beginning of the tile map + sla a + sla a + sla a + ld b, 0 + ld c, a ; need to advance it by a*8 bytes. + add hl, bc + ld b, 8 + : + ld a, [hl+] + ld [de], a + inc de + dec b + jp nz, :- + + ld a, $0c + ld [de], a + + pop af + + ret + + + +BuildTopRow: + ; assuming buffer one contains a sequence of ten tile IDs + ; this writes the tile data for each of those tiles sequentially into BUFFER_TWO + push af + ld hl, BUFFER_ONE + ld de, BUFFER_TWO + ld c, 10 + .loop + push bc + ld a, [hl+] ; fetch a tile ID + push hl + ld hl, UITiles + cp a, 26 + jp c, :+ + ; if the tile id is greater than 26, then we need to fetch from the card data + sub a, 26 ; and undo the offset encoded into the tile map + call FindCardKeyTiles + : + call FindTileData + ; now hl points to tile data, de points to a spot in buffer 2 + ld bc, 16 + call CopyRange + pop hl + pop bc + dec c + jp nz, .loop + ld b, b + pop af + ret +DoubleTheBuffer: + ld hl, BUFFER_TWO + ld de, BUFFER_ONE + + ld a, 10 + .topHalfLoop + push hl + push af + call WriteTopHalfDoubledTile + pop af + pop hl + ld bc, 16 + add hl, bc + dec a + jp nz, .topHalfLoop + + ld hl, BUFFER_TWO + ld a, 10 + .bottomHalfLoop + push hl + push af + ld bc, 8 + add hl, bc + call WriteTopHalfDoubledTile + pop af + pop hl + ld bc, 16 + add hl, bc + dec a + jp nz, .bottomHalfLoop + + ld b, b + ret + +PrintTheBuffer: + call ClearBuffer + + ld a, 4 ; fill buffer + ld hl, BUFFER_ONE + ld bc, $280 + call SendPacket + + call SendEmpty + + call SendPrint + ret + + +WaitForPrintable: + ld a, $F + ld hl, ZEROES + ld bc, 0 + call SendPacket + + ; NONE, READY, ERROR, FULL, PRINTING + + ld a, [vPrinterState] + cp a, PS_PRINTING + ret z + cp a, PS_ERROR + ret z + cp a, PS_NONE + ret z + + call ClearBuffer + + ld a, [vPrinterState] + cp a, PS_FULL + ret z + + ld a, [vPrinterRow] + inc a + ld [vPrinterRow], a + + ret + +DoMiddleRow: + call ClearBuffer + ld a, [vPrinterRow] + srl a + dec a + call SendRowA + call SendEmpty + call SendPrint + ld a, [vPrinterRow] + inc a + ld [vPrinterRow], a + ret +DoBottomRow: + call ClearBuffer + call SendBottomRow + call SendPrint + ld a, [vPrinterRow] + inc a + ld [vPrinterRow], a + ret +FinishUp: + call ClearBuffer + + ld a, 0 + ld [vBlocked], a + ld [vPrinterStart],a + ld [vPrinterRow], a + ld a, 1 + ld [vPrinterIsReady], a + + ret + + +SendEmpty: + ld a, 4 + ld hl, ZEROES + ld bc, 0 + call SendPacket + ret + +SendBottomRow: + ; draw the top of a card + ld de, BUFFER_ONE + + ; top half of border + ld a, $11 + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + + ld c, 8 +.loop + push bc + ld a, $0d + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + pop bc + dec c + ld a, 0 + or a, c + jp nz, .loop + + ld a, $10 + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + + ; bottom half of border + ld a, $11 + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + ld c, 8 +.loop2 + push bc + ld a, $0d + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + pop bc + dec c + jp nz, .loop2 + + ld a, $10 + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + ld a, 4 ; fill buffer + ld hl, BUFFER_ONE + ld bc, $280 + call SendPacket + + ret + +SendTopRow: + ; draw the top of a card + ld de, BUFFER_ONE + + ; top half of border + ld a, $0e + ld hl, UITiles + call FindTileData ; give it a=index into some tiles, hl=what to start from + call WriteTopHalfDoubledTile + + ld c, 8 +.loop + push bc + ld a, $0a + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + pop bc + dec c + ld a, 0 + or a, c + jp nz, .loop + + ld a, $0f + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + + ; bottom half of border + ld a, $0e + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + ld c, 8 +.loop2 + push bc + ld a, $0a + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + pop bc + dec c + jp nz, .loop2 + + ld a, $0f + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + ld a, 4 ; fill buffer + ld hl, BUFFER_ONE + ld bc, $280 + call SendPacket + + ret + +SendRowA: + push af + + ld de, BUFFER_ONE + + ; left side border + ld a, $0b + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + + ; find the row of tile data we're looking for + pop af + push af + ; a might be from 0-16, and we needd to multiply it by 8. that should stay + ; within 256 tho so we can just sla three times + call FindCardTileMap + sla a + sla a + sla a + ld b, 0 + ld c, a + add hl, bc + push hl + ; hl now holds the row of the tile map we're interested in. + ld c, 8 +.loop + push bc + ld a, [hl+] + sub a, 26 ; undo the offset normally encoded into the tile data + push hl + call FindCardKeyTiles + call FindTileData + call WriteTopHalfDoubledTile + pop hl + pop bc + dec c + jp nz, .loop + + ; right side border + + ld a, $0c + ld hl, UITiles + call FindTileData + call WriteTopHalfDoubledTile + + ld a, $0b + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + pop hl + ld c, 8 +.loop2 + push bc + ld a, [hl+] + sub a, 26 ; undo the offset normally encoded into the tile data + push hl + call FindCardKeyTiles + call FindTileData + call WriteBottomHalfDoubledTile + pop hl + pop bc + dec c + ld a, 0 + or a, c + jp nz, .loop2 + + ld a, $0c + ld hl, UITiles + call FindTileData + call WriteBottomHalfDoubledTile + + pop af + ; a holds the row we're on + ld b, 8 ; pre-increment so that when we pre-decrement in the loop later it works + sla a + sla a + sla a ; mullitply by 8 + add a, 24 ; offset for the border and overscan + add a, b ; start from the bottom row of these tiles, a*8 + 7 + .addSpriteLinesLoop + dec a + + ld [vCurrentScanline], a + call AddSpritesToLine + + dec b + jp nz, .addSpriteLinesLoop + .doneAddSpriteLinesLoop + + ld a, 4 ; fill buffer + ld hl, BUFFER_ONE + ld bc, $280 + call SendPacket + + ret + +SendPrint: + call SendEmpty + + ld hl, BUFFER_ONE + ld a, 1 ; number of sheets + ld [hl+], a + ld a, $00 ; margins + ld [hl+], a + ld a, $e4 ; palette + ld [hl+], a + ld a, $7f ; exposure + ld [hl+], a + + ld a, 2 ; print + ld hl, BUFFER_ONE + ld bc, 4 + call SendPacket + ret + + +ClearBuffer: + ld a, $1 + ld hl, ZEROES + ld bc, 0 + call SendPacket + + ret + +PrinterTiles: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + db $00,$1c,$00,$0e,$38,$3f,$64,$7f,$7f,$7f,$7f,$40,$7f,$40,$3f,$3f + db $00,$00,$00,$00,$00,$00,$06,$b6,$ff,$ff,$ff,$11,$ff,$11,$fe,$fe + db $00,$00,$00,$80,$0e,$8e,$12,$9e,$24,$bc,$38,$b8,$00,$80,$00,$00 + db $00,$00,$00,$00,$5a,$5a,$92,$92,$5a,$5a,$52,$52,$9b,$9b,$00,$00 + db $00,$00,$18,$98,$18,$98,$18,$98,$18,$98,$00,$80,$18,$98,$00,$00 + db $00,$00,$00,$00,$d8,$d8,$94,$94,$d8,$d8,$94,$94,$d2,$d2,$00,$00 + db $00,$00,$00,$80,$19,$99,$15,$95,$19,$99,$11,$91,$11,$91,$00,$00 + db $00,$00,$00,$00,$92,$92,$5a,$5a,$96,$96,$52,$52,$52,$52,$00,$00 + db $00,$00,$00,$80,$1d,$9d,$11,$91,$19,$99,$11,$91,$11,$91,$00,$00 + db $00,$00,$00,$00,$52,$52,$52,$52,$52,$52,$52,$52,$db,$db,$00,$00 +PrinterTiles.End: ; $22 + +PrinterNotDetected: + db $00, $00 + db $13, $00 +PrinterAvailable: + db $f1, $f2 + db $f3, $f4 +PrinterPrinting: + db $f1, $f2 + db $f7, $f8 +PrinterError: + db $f1, $f2 + db $f5, $f6 +PrinterFull: + db $f1, $f2 + db $f9, $fa diff --git a/RecreatingCards.inc b/RecreatingCards.inc new file mode 100644 index 0000000..79cd62d --- /dev/null +++ b/RecreatingCards.inc @@ -0,0 +1,393 @@ +; i'm so sorry for this file + +PUSHS "Graphics Variables", WRAM0[PRINTER_VARS_START+$80] +vCurrentLineOAMOffsets: ds 16 ; 10 bytes which each store an offset into MY_OAM +vCurrentScanline: db ; what scanline are we looknig at +vCurrentDotX: db ; what x position we're looknig at +vCurrentPixelColor: db ; the pixel we're looking at's color value, 2 bits +vTopHalfOfSprite: ds $20 ; two tiles of tile data for the top half of a sprite +vBottomHalfOfSprite: ds $20 ; two tiles of tile data for the bottom half of a sprite +POPS + +BuildRelevantSpritesList: + ld a, 0 ; a should now hold how many sprites we've looked at for this row + push af + + ld de, vCurrentLineOAMOffsets + ld a, $ff + ld b, 14 + ; populatte oam offsets with $ff, an indicator that no sprite is found + .buildBlankList + ld [de], a + inc de + dec b + jp nz, .buildBlankList + + ld de, vCurrentLineOAMOffsets + ld bc, $0000 ; starting offset + + .loop + pop af ; counter for how many sprites we've added on thiis row + call IsThisSpriteRelevant + call c, AddThisSpriteToDE ; if it is relevant tthen add it + push af ; save the counter for the next row + cp a, 10 ; if the new counter is 10, then we're full up! and done w sprites + jp z, .doneWithOAM + inc c + inc c + inc c + inc c + ld a, c + cp a, $A0 + jp z, .doneWithOAM + jp .loop + .doneWithOAM + pop af + ld a, [vCurrentScanline] + ret + +IsThisSpriteRelevant: + push af ; don't wanna squash a + ; bc is an offset into an OAM + ; set the carry flag if we have to draw the sprite at OAM+bc on ths line. + + ld hl, MY_OAM + + ld a, [vCurrentScanline] + add hl, bc ; get OAM record. first byte is y value + sub a, [hl] ; vCurrentScanline - yvalue + jp c, .irrelevant ; if it carries, then the sprite is strrictly greater + ; than scanline. not relevant. + cp a, 8 + jp nc, .irrelevant ; if it doesn't carry, then a-[hl] is greater than or + ; equal to 8. not relevant. + .relevant + ; if it doesn't satisfy either of those circumstances, then it's relevant. + pop af + scf ; set carry + ret + .irrelevant + pop af + scf + ccf ; clear carry = set carry + complement carry + ret + +AddThisSpriteToDE: + inc a ; increment a to signal we've added a sprite to the relevant sprites + push af + ld a, c ; bc holds hte offset iinto OAM, which always sstarts with $00 + ld [de], a + inc de + pop af + ret + +AddSpritesToLine: +; operates on sscanline [vCurrentScanline] and buffer BUFFER_ONE + push af + push bc + + call BuildRelevantSpritesList + + ld a, 16 ; account for border + ld [vCurrentDotX], a + .loopOverX + call GetCurrentBackgroundPixelValueFromBuffer + + ld hl, vCurrentLineOAMOffsets + .loopOverSprites + ld b, 0 + ld c, [hl] + bit 0, c + jp nz, .doneLoopingOverSprites ; if we find an offset with the first bit set + ; then it has to be an endd-of-list flag so we're done looping over sprites. + ; otherrwise we have a valid sprite offset in bc + + push hl ; push hl (position in vCurrentLineOAMOffsees) to save for later + ; this is popped in .nextSprite + + ld hl, MY_OAM + add hl, bc ; index into MY_OAM + inc hl ; we're already certain it's in the range for y, so look at x + ld a, [vCurrentDotX] ; current x value + sub a, [hl] ; dx = x - sx -> if it carries, we skip + jp c, .nextSprite + cp a, 8 ; dx - 8 -> if it doesn't carry, we skip + jp nc, .nextSprite + + dec hl ; look at whole oam record + ;now we've ensured that 0 <= dx < 8 + ;get pixel A from sprite in oam + + ; a holds dx + ; hl holds an OAM record + call GetPixelFromOAM + ; a now holds a color id. if thatt color id is zero, go to the next sprite + ; hl points to the OAM record + cp a, 0 + jp z, .nextSprite + push af ; hold on to color id. + inc hl ; point to x value + inc hl ; point tto tile id + inc hl ; point to attributes + ; palette is bit 4 [hl] + ; priority is bit 7 [hl] + + bit OAMB_PRI, [hl] ; if priority is zero, continue writing sprite color (skip this block) + jp z, :+ + ld a, [vCurrentPixelColor] ; else priority iis 1 + cp a, 0 + jp z, :+ ; if priority is 1 and background is zero, continue writing sprite color + pop af ; gotta get that off the stack so it's clean + jp .doneLoopingOverSprites ; if priiority is 1 AND backgruond is nonzero, + ; we're done with this pixel forever. this does not properly deal with priority + ; but it should be good enough for thiis program. + : + pop af + cp a, 0 + jp z, .nextSprite ; if the color index of the sprite is zero, then we can skip + push af + + ; get color from palette + ld a, [rOBP0] + bit OAMB_PAL1, [hl] + jp z, :+ + ld a, [rOBP1] + : + ld b, a ; put the palette into b + pop af + ; right shift the palette to get the specific color + ; index (a) guaranteed to not be zero bc we checked for that above + : + srl b + srl b + dec a ; shift right twice per color index + jp nz, :- + ld a, b + and a, $3 ; now holds just the color itself + + + call WritePixelToBuffer + + .nextSprite + pop hl + inc hl + jp .loopOverSprites + .doneLoopingOverSprites + + ld hl, vCurrentDotX + inc [hl] + ld a, 80 + cp a, [hl] + jp nc, .loopOverX + + pop bc + pop af + ret + +GetPixelFromOAM: +; hl takes an oam record +; a has an x offset +; bit 5, [hl+3] = x flip +; de takes the yx offsets + push hl + push de + ld e, a ; hold on to x offset + ld a, [vCurrentScanline] ; y position + sub a, [hl] ; currentScanline - y position + ld d, a ; hold on to y offset + inc hl ; look at x coord + inc hl ; look at tile id + + ld a, [hl] + call FindCardSpriteTiles ; puts card sprite tiles in hl + call FindTileData ; uses a + hl to get tile data + + ld a, d ; y offset is number of pairs of bytes to skip + cp a, 0 + jp z, .doneFindingYLine + .loopFindYLine + inc hl + inc hl + dec a + jp nz, .loopFindYLine + .doneFindingYLine + + ;now hl points to two bytes which correspond to the correct tile data. + ; abcd_efghi jklm_nopq + ld b, [hl] ; first bitplane + inc hl + ld c, [hl] ; second bitplane + + ld a, 7 + sub a, e ; number of times to shift right to put the bit we want in positoin 0 + cp a, 0 + jp z, .doneShiftingBC + .shiftbc + srl b + srl c + dec a + jp nz, .shiftbc + .doneShiftingBC + ld a, b + and a, $1 + ld b, a + + sla c + ld a, c + and a, $2 + or a, b ; now a holds the color id!! + + pop de + pop hl + ret + +GetCurrentBackgroundPixelValueFromBuffer: +; takes arguments from vCurrentScanline and vCurrentDotX, gets the two-bit pixel +; value from the tile data llinearly packed at BUFFER_ONE + call FindCurrentBufferBytes + ; sets hl and bc. b = msb tile, c = lsb tile + + ld a, [vCurrentDotX] + and a, $7 + ld e, a ; e = x % 8 = xoff + + ; now extract the specific pixel + ld a, 7 + sub a, e ; 7-xoff = number of times to shift to the right + cp a, 0 + jp z, .doneBitShifting + .bitShiftLoop + srl b + srl c + dec a + jp nz, .bitShiftLoop + .doneBitShifting + ld a, b + and a, $1 + sla a + ld b, a + ld a, c + and a, $1 + or a, b + + ld [vCurrentPixelColor], a + ret + +WritePixelToBuffer: +; takes 2-bit color as a, yx offsets as de. +; overwrites the pixel in the buffer with the color passed in. + ld b, a ; hold on to the color we're trying to write + and a, $1 ; LSB first + ld c, a + ld a, b + sra a ; MSB next + ld b, a ; now b and c hold msb and lsb + + ld a, 7 + sub a, e ; get x offset from right side (7-xoff) + + jp z, :++ + : + sla b + sla c + dec a + jp nz, :- + : + ; now b and c have been shifted left according to their values. + push bc + call FindCurrentBufferBytes + call WipeTargetBit + pop bc + ld a, c + or a, [hl] + ld [hl], a ; lsb first + + inc hl + + ld a, b + or a, [hl] + ld [hl], a + + ret + + +WipeTargetBit: +; hl points to a row, e holds an xoff +; sets the xoff bit of [hl] and [hl+1] to zero + ; gonna make a mask that has 1s everywhere except for a zero at bit xoff + push de + ld d, $7F + + ; shift right by e bits + ld a, 0 + cp a, e + ld a, d + jp z, :++ + : + srl a + or a, $80 + dec e + jp nz, :- + : + + ; apply the mask witth AND to [hl] and [hl+1] + ld d, a + + ;ld a, d + and a, [hl] + ld [hl], a + + inc hl + + ld a, d + and a, [hl] + ld [hl], a + + dec hl + + pop de + + ret + + + +FindCurrentBufferBytes: +; points hl at the bytes of BUFFER_TWO where the current scanline/dot live + ld a, [vCurrentScanline] + sub a, 16 ; subtract off the overscan + and a, $7 ; scanline mod 8, so we can step through the buffer + ld d, a ; store y offset within this row of tiles + ld a, [vCurrentDotX] + sub a, 8 ; subtract off the overscan + and a, $7 ; current dot mod 8, for an offste + ld e, a + ld a, [vCurrentDotX] + sub a, 8 ; subtract off the border + sra a + sra a + sra a ; divide a by 8 to geet numbre of tiles we want to step past + + ; now we want to get hl to point to the two bytes which define the pixel we want. + ld h, 0 + ld l, a ; numbeer of tiles we want to step past. 16 bytes per this + add hl, hl ; number of tiles times 2 + add hl, hl ; times 4 + add hl, hl ; times 8 + add hl, hl ; tmies 16 si the number of bytes to step forward + + ld bc, BUFFER_TWO + add hl, bc ; this is pointing at the start of a tile. + + ; now step down by 2*d bytes to get the row we want + ld b, 0 + ld c, d ; this is the y offset + ; add twice y offset to hl to get the row we want. + add hl, bc + add hl, bc ; now we're pointing at the two bytes we want to extract a pixel from. + ld c, [hl] ; LSB fiirst + inc hl + ld b, [hl] ; MSB second + dec hl + + ret + diff --git a/ScreenCardBrowse.inc b/ScreenCardBrowse.inc index 6cc97ab..d6d7178 100644 --- a/ScreenCardBrowse.inc +++ b/ScreenCardBrowse.inc @@ -1,4 +1,10 @@ ; screen variables shared with screencardread +PUSHS UNION "Screen Variables", WRAM0[SCREEN_VARS_START] +ds 32 ; why are we putting this so far in? i don't remember but whatever +vPrintJobState: db ; start, wait til ready, top row, row a, wait, printing, bottom row +vPrintingRow: db +vExposureSetting: db +POPS ScreenCardBrowse: dw CardBrowseSetup @@ -9,6 +15,7 @@ ScreenCardBrowse: CardBrowseSetup: ld a, 1 ld [vBlocked], a + ld [vTooBusyForPrinter], a ; make sure working oam is clear ld hl, ZEROES @@ -22,8 +29,13 @@ CardBrowseSetup: ret .asyncTask: + ld hl, PrinterTiles + ld de, _VRAM + $1000 - $10*16 + ld bc, PrinterTiles.End - PrinterTiles + call CopyRange + ld hl, CardBrowse.UITilemap ; origin - ld de, $9800 ; destination + ld de, _SCRN0 ; destination ld b, 18 ; height ld c, 20 ; width call CopyTilesToMap @@ -55,6 +67,25 @@ CardBrowseUpdate: ld [vFrameCountSquares], a .doneTimer + ld a, [vTooBusyForPrinter] + cp a, 0 + jp nz, .donePrinter + + call CheckForPrinter + call UpdatePrintUI + call RunPrintJob + + ld hl, rMYBTNP + bit 6, [hl] ; check select? + jp z, .donePrinter + + ld a, [vPrinterState] + cp a, PS_READY + jp nz, .donePrinter + + call KickOffPrintJob + ret +.donePrinter ld hl, rMYBTNP bit 4, [hl] jp z, .doneWithB @@ -87,6 +118,8 @@ CardBrowseUpdate: cp a, 0 ret nz + ld a, 1 + ld [vTooBusyForPrinter], a ld hl, RefreshCardTask call Async_Spawn_HL @@ -114,25 +147,36 @@ CardBrowseDraw: ld b, [hl] ld h, b ld l, c - ld de, $8000+$100*16 + 1*16 + ld de, _VRAM + $1000 + 1*16 ld bc, (SquaresTileset8 - SquaresTileset7) / 8 - call CopyRangeUnsafeBy8s + call CopyRangeBy8s call CardDraw ld de, SAFE_DMA_LOCATION ld a, HIGH(MY_OAM) call RunDMA + + ld hl, vPrinterReturnValue + ld de, _SCRN0 + 32*6 + 12 + call DrawByte + ld hl, vPrinterReturnValue+1 + ld de, _SCRN0 + 32*6 + 14 + call DrawByte ret + + RefreshCardTask: ld a, [vSelectedCardIndex] ld [vPreviousCardIndex], a - + call DrawDeckMinimap call LoadCardData - di - nop + call UpdatePrintUIImmediate + + ld a, 0 + ld [vTooBusyForPrinter], a ret DrawDeckMinimap: @@ -144,7 +188,7 @@ DrawDeckMinimap: ld hl, vSelectedCardIndex ld d, [hl] ; selected card! ld b, $ff ; start at -1 lol - ld hl, $9800 + 32 + 11 + ld hl, _SCRN0 + 32 + 11 .loop inc b @@ -152,7 +196,7 @@ DrawDeckMinimap: cp a, 5 jp nz, .noNewLine ld [hl], $13 - ld hl, $9800 + 32*2 + 11 + ld hl, _SCRN0 + 32*2 + 11 .noNewLine ld a, b cp a, c @@ -186,10 +230,10 @@ CardBrowseTeardown: CardBrowse.UITilemap: - db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $09, $02, $02, $02, $02, $02, $02, $02, $08, $01 - db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 - db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 - db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $06, $05, $05, $05, $05, $05, $05, $05, $07, $01 + db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $09, $02, $02, $02, $02, $02, $02, $02, $02, $08 + db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04 + db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04 + db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $06, $05, $05, $05, $05, $05, $05, $05, $05, $07 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 diff --git a/ScreenCardRead.inc b/ScreenCardRead.inc index c5f73eb..b7e7272 100644 --- a/ScreenCardRead.inc +++ b/ScreenCardRead.inc @@ -1,5 +1,5 @@ PUSHS UNION "Screen Variables", WRAM0[SCREEN_VARS_START] -ds 16 ; why are we putting this so far in? +ds 16 ; why are we putting this so far in? i don't remember but whatever vPreviousCardIndex: db POPS @@ -25,7 +25,7 @@ CardReadSetup: .asyncTask: ld hl, CardRead.UITilemap ; origin - ld de, $9800 ; destination + ld de, _SCRN0 ; destination ld b, 18 ; height ld c, 20 ; width call CopyTilesToMap @@ -112,7 +112,7 @@ CardReadDraw: ld b, [hl] ld h, b ld l, c - ld de, $8000+$100*16 + 1*16 + ld de, _VRAM + $1000 + 1*16 ld bc, (SquaresTileset8 - SquaresTileset7) / 8 call CopyRangeUnsafeBy8s @@ -135,7 +135,7 @@ ChangedCardTask: ld c, a ld a, [vCurrentSpread+1] ld b, a ; gett bc as cuurrent spread address - ld hl, $9800 + (32*1)+11 + ld hl, _SCRN0 + (32*1)+11 ld a, [vSelectedSpreadCard] call DrawSpreadMinimap @@ -153,9 +153,9 @@ ChangedCardTask: dec a jp .loopThroughSpreadPositions .foundSpreadPositionDescription - ld de, $9800 + 32*5 + 11 + ld de, _SCRN0 + 32*5 + 11 call PrintString - ld de, $9800 + 32*6 + 11 + ld de, _SCRN0 + 32*6 + 11 call PrintString ld hl, SHUFFLED_DECK+1 diff --git a/ScreenMainMenu.inc b/ScreenMainMenu.inc index 68b9aee..e394d04 100644 --- a/ScreenMainMenu.inc +++ b/ScreenMainMenu.inc @@ -39,8 +39,8 @@ MainMenuSetup: ldh [rLCDC], a ld hl, SquaresTileset8 - ld de, $8010 + $80*16 - ld bc, 16 + ld de, _VRAM + $1000 + $10 + ld bc, SquaresTilesetEnd - SquaresTileset8 ;println "the diff is ", SquaresTilesetEnd - SquaresTileset8 call CopyRange @@ -97,19 +97,19 @@ MainMenuSetup: def TileStartCardBackSprites16 equ TileStartCardBackSprites17 + spacing ld hl, MainUITilemap - ld de, $9800 + ld de, _SCRN0 ld b, 18 ld c, 20 call CopyTilesToMap ld hl, StringRead - ld de, $9800 + 32*11 + 4 + ld de, _SCRN0 + 32*11 + 4 call PrintString ld hl, StringShuffle - ld de, $9800 + 32*13 + 4 + ld de, _SCRN0 + 32*13 + 4 call PrintString ld hl, StringBrowse - ld de, $9800 + 32*15 + 4 + ld de, _SCRN0 + 32*15 + 4 call PrintString @@ -130,6 +130,9 @@ MainMenuSetup: ld a, %11100100 ldh [rBGP], a ldh [rOBP0], a + + ld hl, .doNothing + call Async_Spawn_HL ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16 ldh [rLCDC], a @@ -198,7 +201,8 @@ MainMenuSetup: ; load graphics into vram for deck face ; set up variables: LFSR stuff ret ; return from cardreadsetup - +.doNothing + ret MainMenuUpdate: ; if pressing a key and unblocked: ; signal an animation to start @@ -371,7 +375,7 @@ MainMenuDraw: ld b, [hl] ld h, b ld l, c - ld de, $8000+$100*16 + 1*16 + ld de, _VRAM + $100*16 + 1*16 ld bc, (SquaresTileset8 - SquaresTileset7) / 8 call CopyRangeUnsafeBy8s @@ -379,7 +383,7 @@ MainMenuDraw: ld c, 32 ; find the location of the last selected caret and make it blank - ld hl, $9800 + 32*11 + 3 - 64 + ld hl, _SCRN0 + 32*11 + 3 - 64 ld a, [vMenuIndexPrevious] inc a .findLastCaret @@ -391,7 +395,7 @@ MainMenuDraw: ;find the location of the new selected caret and make it a caret ; bc contains 32 (row stride of bgmap) - ld hl, $9800 + 32*11 + 3 - 64 + ld hl, _SCRN0 + 32*11 + 3 - 64 ld a, [vMenuIndex] inc a .findNewCaret diff --git a/ScreenSpreadSelect.inc b/ScreenSpreadSelect.inc index 517a4dc..0ad4653 100644 --- a/ScreenSpreadSelect.inc +++ b/ScreenSpreadSelect.inc @@ -24,22 +24,21 @@ SpreadSelectSetup: ret -.asyncTask ; setup task to be executed async +.asyncTask: ; setup task to be executed async ld a, HIGH(ZEROES) ld de, SAFE_DMA_LOCATION call RunDMA ld hl, SpreadSelectTilemap - ld de, $9800 + ld de, _SCRN0 ld b, 18 ld c, 20 - call CopyTilesToMapUnsafe + call CopyTilesToMap ld hl, CardPartTiles - ld de, $9000 - ($10)*16 + ld de, _VRAM + $1000 - ($10)*16 ld bc, CardPartTilesEnd - CardPartTiles - - call CopyRangeUnsafe + call CopyRange call DrawSpreadTask ld a, 0 @@ -216,7 +215,7 @@ UpdateCurrentSpread: DrawSpreadTask: ; draw the spread large in the middle of the screen, and descs ; clear the space to scrolling background tiles - ld de, $9800 + 32*5 + 3 + ld de, _SCRN0 + 32*5 + 3 ld hl, ONES ld b, 8 ld c, 14 @@ -237,11 +236,11 @@ DrawSpreadTaskWithoutRefreshingBackgroundFirst: jp nz, .PassCardPositionDescriptions ; now hl is pointing at the title string - ld de, $9800 + 32 + 1 + ld de, _SCRN0 + 32 + 1 call PrintString ; now hl is pointing at the description - ld de, $9800 + (32*2) + 1 + ld de, _SCRN0 + (32*2) + 1 call PrintString call DrawSpreadCards @@ -251,7 +250,7 @@ DrawSpreadTaskWithoutRefreshingBackgroundFirst: ret DrawSpreadCards: - ld hl, $9800 + 32*5 + 3 + ld hl, _SCRN0 + 32*5 + 3 ld a, [vSelectedSpreadCard] ld d, 0 ld e, a ; e contains the selected index @@ -273,9 +272,9 @@ DrawSpreadCards: dec e jp nz, .stepForwardCardDescription .printIt - ld de, $9800+32*15 + 6 + ld de, _SCRN0 + 32*15 + 6 call PrintString - ld de, $9800+32*16 + 6 + ld de, _SCRN0 + 32*16 + 6 call PrintString ret @@ -293,7 +292,7 @@ SpreadSelectDraw: ld b, [hl] ld h, b ld l, c - ld de, $8000+$100*16 + 1*16 + ld de, _VRAM + $100*16 + 1*16 ld bc, (SquaresTileset8 - SquaresTileset7) / 8 call CopyRangeUnsafeBy8s diff --git a/card_art/PrinterTiles.asm b/card_art/PrinterTiles.asm new file mode 100644 index 0000000..90755d3 --- /dev/null +++ b/card_art/PrinterTiles.asm @@ -0,0 +1,38 @@ + ; original export script by gabriel reis, modified by shoofle + + +PrinterTiles: + + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + db $00,$1c,$00,$0e,$38,$3f,$64,$7f,$7f,$7f,$7f,$40,$7f,$40,$3f,$3f + db $00,$00,$00,$00,$00,$00,$06,$b6,$ff,$ff,$ff,$11,$ff,$11,$fe,$fe + db $00,$00,$00,$80,$0e,$8e,$12,$9e,$24,$bc,$38,$b8,$00,$80,$00,$00 + db $00,$00,$00,$00,$5a,$5a,$92,$92,$5a,$5a,$52,$52,$9b,$9b,$00,$00 + db $00,$00,$18,$98,$18,$98,$18,$98,$18,$98,$00,$80,$18,$98,$00,$00 + db $00,$00,$00,$00,$d8,$d8,$94,$94,$d8,$d8,$94,$94,$d2,$d2,$00,$00 + db $00,$00,$00,$80,$19,$99,$15,$95,$19,$99,$11,$91,$11,$91,$00,$00 + db $00,$00,$00,$00,$92,$92,$5a,$5a,$96,$96,$52,$52,$52,$52,$00,$00 + db $00,$00,$00,$80,$1d,$9d,$11,$91,$19,$99,$11,$91,$11,$91,$00,$00 + db $00,$00,$00,$00,$52,$52,$52,$52,$52,$52,$52,$52,$db,$db,$00,$00 + + + +PrinterUI: + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $09, $0a, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $02, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $04, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $05, $06, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $08, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 diff --git a/card_art/screendesigns.aseprite b/card_art/screendesigns.aseprite index 34bdc8d..865c4c9 100644 Binary files a/card_art/screendesigns.aseprite and b/card_art/screendesigns.aseprite differ diff --git a/gb_tarot_theme.s3m b/gb_tarot_theme.s3m index 7c378f8..6094e45 100644 Binary files a/gb_tarot_theme.s3m and b/gb_tarot_theme.s3m differ diff --git a/gbmnopedie.flac b/gbmnopedie.flac new file mode 100644 index 0000000..20ba105 Binary files /dev/null and b/gbmnopedie.flac differ diff --git a/gbmnopedie.mp3 b/gbmnopedie.mp3 new file mode 100644 index 0000000..0b5826c Binary files /dev/null and b/gbmnopedie.mp3 differ diff --git a/gbmnopedie.s3m b/gbmnopedie.s3m new file mode 100644 index 0000000..6f70382 Binary files /dev/null and b/gbmnopedie.s3m differ diff --git a/gbmnopedie.wav b/gbmnopedie.wav new file mode 100644 index 0000000..8f739ac Binary files /dev/null and b/gbmnopedie.wav differ diff --git a/main.asm b/main.asm index c5d8c1c..5764f54 100644 --- a/main.asm +++ b/main.asm @@ -3,6 +3,9 @@ ; alex for consulting on tarot endlessly ; moss for keeping me from working sixteen hours a day and burning out ; yuri for letting me bounce ideas off you at all times +; sara for being a perfect light +; fae for all your help on music and sound and sunday mornings +; sadie for hardware and packaging help @@ -36,10 +39,17 @@ def CARD_HELPER_VARS_START equ $c600 ; variables for card data def CARD_VARS_START equ $c700 ; variables for animation of individual cards def CVS equ CARD_VARS_START ; handy to be able to refer to CVS by a short name def AUDIO_VARS_START equ $c800 ; variables for the audio subsystem -def SHUFFLED_DECK equ $c900 ; location for the shuffled deck +def PRINTER_VARS_START equ $c900 +def SHUFFLED_DECK equ $ca00 ; location for the shuffled deck + +pushs "work spaces", WRAMX[$D000] +ZEROES: ds $200 +ONES: ds $200 +BUFFER_ONE: ds $300 +BUFFER_TWO: ds $300 +pops + -def ZEROES equ $D000 -def ONES equ $D200 ; system variables, which are like program-wide state vars but More Different PUSHS "System Variables", WRAM0[SYSTEM_VARS_START] @@ -107,12 +117,12 @@ EntryPoint: jp nz, .buildOnes ld hl, UITiles - ld de, $8000 + $100*16 + ld de, _VRAM + $1000 ld bc, UITiles.end - UITiles call CopyRange ld hl, LetterTiles ; map the small font into vram at ascii locations - ld de, $8000 + (127 + $11)*16 + ld de, _VRAM + $800 + ($10)*16 ld bc, LetterTiles.end - LetterTiles call CopyRange @@ -229,6 +239,8 @@ EntryPoint: call SoundSetup + call PrepNetwork + Loop: ; okay this is kinda sketchy. we want a delta time variable. ; we've got two eight-bit counters, one at 4096hz and one at 16384hz @@ -562,6 +574,9 @@ INCLUDE "CopyRange.inc" INCLUDE "CopyTiles.inc" INCLUDE "Async.inc" INCLUDE "Random.inc" +INCLUDE "RecreatingCards.inc" +INCLUDE "GraphicsManipulation.inc" +INCLUDE "Printing.inc" INCLUDE "ScreenMainMenu.inc" INCLUDE "ScreenSpreadSelect.inc" INCLUDE "CardHelpers.inc" @@ -573,4 +588,3 @@ INCLUDE "CardLibrary.inc" INCLUDE "Audio.inc" -INCLUDE "theme.inc" diff --git a/s3m2shoofmt.py b/s3m2shoofmt.py index 3c6cb48..b30032f 100644 --- a/s3m2shoofmt.py +++ b/s3m2shoofmt.py @@ -436,7 +436,7 @@ def effect_s3m_to_gb(channel, effectnum, effectparams): return (EFFECT_PAN, val) elif subeffectnum == 0xC: # Notecut - print(f"found a note cut! with params {subeffectparams}") + print(f"found ay note cut! with params {subeffectparams}") return (EFFECT_NOTE_CUT, subeffectparams) elif subeffectnum == 0xF: # Funkrepeat? Set active macro? diff --git a/shoofles_audio_engine_test.s3m b/shoofles_audio_engine_test.s3m new file mode 100644 index 0000000..d3d5767 Binary files /dev/null and b/shoofles_audio_engine_test.s3m differ diff --git a/source.zip b/source.zip index 64ecc98..3a6ca84 100644 Binary files a/source.zip and b/source.zip differ