Skip to content

Commit

Permalink
Implemented RX routine framework
Browse files Browse the repository at this point in the history
  • Loading branch information
cspang1 committed May 10, 2018
1 parent 60b7ccc commit c3445dd
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 14 deletions.
12 changes: 10 additions & 2 deletions Dev/Game/Software/txrx.spin
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@ CON
OBJ
vga_tx : "vga_tx" ' Import graphics transmission system
vga_rx : "vga_rx" ' Import graphics reception system
serial : "FullDuplexSerial"

VAR
' Video system pointers
long cur_scanline_base_ ' Register in Main RAM containing current scanline being requested by the VGA Display system

PUB main | time
serial.Start(31, 30, %0000, 57600) 'requires 1 cog for operation
waitcnt(cnt + (1 * clkfreq)) 'wait 1 second for the serial object to start

' Start video system
vga_tx.start(@testing) ' Start graphics transmission
vga_tx.start(@input)
vga_rx.start(@output)
time := cnt

repeat
waitcnt(time += (clkfreq/60))
vga_tx.transmit
serial.Str(LONG[@output][0]) 'print a test string
serial.Tx($0D) 'print a new line

DAT
testing long %10101010_10101010_10101010_10101010[((40*30*2)+(32*16)*2+(64*4))/4]
input long $AAAA_AAAA[((40*30*2)+(32*16)*2+(64*4))/4]
output long 0[((40*30*2)+(32*16)*2+(64*4))/4]
122 changes: 117 additions & 5 deletions Dev/Game/Software/vga_rx.spin
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,145 @@
File: vga_rx.spin
Author: Connor Spangler
Date: 5/1/2018
Version: 0.1
Version: 0.2
Description:
This file contains the PASM code to receive graphics resources from
another Propeller
}}

CON
BUFFER_SIZE = ((40*30*2)+(32*16)*2+(64*4))/4 ' Size of transmission buffer in LONGs (tile map + color palettes + SAT)

VAR
long cog_ ' Variable containing ID of reception cog
long var_addr_base_ ' Variable for pointer to base address of Main RAM variables
long cont_ ' Variable containing control flag for transmission routine

PUB start(varAddrBase) : status ' Function to start reception driver with pointer to Main RAM variables
stop ' Stop any existing reception cogs

' Instantiate variables
var_addr_base_ := varAddrBase ' Assign local base variable address

' Start reception driver
ifnot cog_ := cognew(@rx, var_addr_base_) + 1 ' Initialize cog running "rx" routine with reference to start of variable registers
ifnot cog_ := cognew(@rx, @var_addr_base_) + 1 ' Initialize cog running "rx" routine with reference to start of variable registers
return FALSE ' Reception system failed to initialize

return TRUE ' Reception system successfully initialized

PUB receive
repeat until cont_
cont_ := FALSE

PUB stop ' Function to stop reception driver
if cog_ ' If cog is running
cogstop(cog_~ - 1) ' Stop the cog

DAT
org 0
' Start of the graphics data transmission routine
rx jmp #rx ' Loop infinitely
rx
' Initialize variables
mov bufptr, par
add cntptr, bufptr ' Initialize pointer to control flag
rdlong bufptr, par ' Initialize pointer to variables

' Initialize pins
andn dira, RxPin ' Set output pin {{ DOES THIS BREAK??? }}
or outa, RxPin ' Set pin high for ACK

' Receive graphics buffer
rxbuff mov bufsiz, BuffSz ' Initialize graphics buffer size
mov curlng, bufptr ' Initialize graphics buffer location

' Receive long
:rxlong mov rxval, #0 ' Zero reception long buffer {{ NECESSARY??? }}
waitpeq RxPin, RxPin ' Wait for ACK

' Receive bits
:rxbits test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit
test RxPin, ina wc ' Get bit
rcl rxval, #1 ' Shift in bit

' Store long and prepare for the next
wrlong rxval, curlng ' Store current long
add curlng, #4 ' Increment to next graphics buffer long
djnz bufsiz, #:rxlong ' Repeat for all longs in buffer

' Prepare for next buffer reception
wrlong RxCont, curlng ' Set control flag for next reception
or dira, RxPin ' Set RX pin as output for ACK
andn dira, RxPin ' Set RX pin as input
jmp #rxbuff ' Loop infinitely

BuffSz long BUFFER_SIZE ' Size of graphics buffer
bufptr long 0 ' Pointer to reception buffer in main RAM w/ offset
cntptr long 4 ' Pointer to reception control flag in main RAM w/ offset
RxPin long |< 0 ' Set reception pin
RxCont long FALSE ' High transmission start pulse

bufsiz res 1 ' Container for size of graphics buffer
curlng res 1 ' Container for current long address
rxval res 1 ' Container for current long

fit
fit
16 changes: 9 additions & 7 deletions Dev/Game/Software/vga_tx.spin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: vga_tx.spin
Author: Connor Spangler
Date: 5/1/2018
Version: 0.2
Version: 1.0
Description:
This file contains the PASM code to transmit graphics resources from one
Propeller to another
Expand All @@ -17,6 +17,8 @@ VAR
long cont_ ' Variable containing control flag for transmission routine

PUB start(varAddrBase) : status ' Function to start transmission driver with pointer to Main RAM variables
stop ' Stop any existing transmission cogs

' Instantiate variables
var_addr_base_ := varAddrBase ' Assign local base variable address
cont_ := FALSE ' Instantiate control flag
Expand Down Expand Up @@ -48,21 +50,21 @@ tx
or dira, TxPin ' Set output pin

' Transfer entire graphics buffer
txbuff mov bufsiz, BuffSz ' Instantiate graphics buffer size
mov curlng, bufptr ' Instantiate graphics buffer location
txbuff mov bufsiz, BuffSz ' Initialize graphics buffer size
mov curlng, bufptr ' Initialize graphics buffer location

' Wait for control flag to go high
:wait rdlong poll, cntptr wz ' Poll control flag
if_z jmp #:wait ' Loop while low

' Transfer current long of graphics buffer
:txlong rdlong txlong, curlng ' Load current long
:txlong rdlong txval, curlng ' Load current long
add curlng, #4 ' Increment to next graphics buffer long
mov txindx, #31 ' Load number of bits in long

' Setup long transmission start
mov phsa, TxStart ' Send one bit high
mov phsa, txlong ' Stage long for transfer
mov phsa, txval ' Stage long for transfer

' Transmit bits
:txbits shl phsa, #1 ' Shift next bit to transmit
Expand All @@ -88,9 +90,9 @@ zero long 0
bufptr long 0 ' Pointer to transmission buffer in main RAM w/ offset
cntptr long 4 ' Pointer to transmission control flag in main RAM w/ offset

curlng res 1 ' Container for current long address
bufsiz res 1 ' Container for size of graphics buffer
txlong res 1 ' Container for the currently transferring graphics buffer long
curlng res 1 ' Container for current long address
txval res 1 ' Container for current long
txindx res 1 ' Container for index of current graphics buffer long bit being transferred
poll res 1 ' Container for polled control flag

Expand Down

0 comments on commit c3445dd

Please sign in to comment.