Files
SyncHome/trunk/workspace/gcb/tiny84-joystick.gcb
2023-03-09 12:51:54 +00:00

149 lines
4.8 KiB
Plaintext

' ########### start ###########
' avr:tiny84
' ########### end ###########
'
' 8MHz, internal RC Oscillator
' Fuses:
' AVRDude: avrdude -B 10 -c USBasp -p attiny84 -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
'----------------------------------------------------------------------
' Joystick adapter Nintendo SNES to AMIGA
' 2016-01-21 (c) Paolo Iocco
'
' Circuit diagram
' ---------------
' ATTiny84
' VCC-------->| |<--------GND
' PB0-------->| |<--------PA0
' PB1-------->| |<--------PA1
' PB3/Reset-->| |---------PA2
' PB2---------| |---------PA3
' PA7---------| |---------PA4 SCK
' PA6 MOSI----| |---------PA5 MISO
'
' 16C84
' PA2 -----| |----- PA1
' PA3 -----| |----- PA0
' PA4 -----| |<---------H
' RST ------>| |<---------H
' GND ------>| |<--------+5V
' PB0 -----| |----- PB7
' PB1 -----| |----- PB6
' PB2 -----| |----- PB5
' PB3 -----| |----- PB4
'----------------------------------------------------------------------
'
' SNES STANDARDS
' ~~~~~~~~~~~~~~
'
' Pinout for SNES gamepads and mice
'
' +-----------------------\
' 7 | o o o o | x x o | 1
' +-----------------------/
' | | | | |
' | | | | +-> Ground
' | | | +------------> Data
' | | +---------------> Latch
' | +------------------> Clock
' +---------------------> Power
' ____
'LATCH _| |_________________________________________________________
' _______ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ___________
'CLOCK |_||_||_||_||_||_||_||_||_||_||_||_||_||_||_|
' ____ _________
'DATA |B |Y |SI|SU|UP|DN|LE|RI|A |X |L |R |? |? |? |? |(16 bit)
'
'
'----------------------------------------------------------------------
'
' DB9 STANDARDS
' ~~~~~~~~~~~~~
'
' Atari MSX
'
' +-----------> Power
' +---------> Right | +---------> Right
' | +-------> Left | | +-------> Left
' | | +-----> Down | | | +-----> Down
' | | | +---> Up | | | | +---> Up
' | | | | | | | | |
' _____________ _____________
' 5 \ x o o o o / 1 5 \ o o o o o / 1
' \ x o o o / \ o o o o /
' 9 `~~~~~~~' 6 9 `~~~~~~~' 6
' | | | | | | |
' | | +----> Button | | | +----> Button 1
' | +------> Power | | +------> Button 2
' +--------> Ground | +--------> Output 3
' +----------> Ground
'
' Commodore AMIGA
'
' +---------> Right +---------> Right
' | +-------> Left | +-------> Left
' | | +-----> Down | | +-----> Down
' | | | +---> Up | | | +---> Up
' | | | | | | | |
' _____________ _____________
' 5 \ x o o o o / 1 5 \ x o o o o / 1
' \ x o x o / \ o o o o /
' 9 `~~~~~~~' 6 9 `~~~~~~~' 6
' | | | | | |
' | +----> Button | | | +----> Button 1
' +--------> Ground | | +------> Power
' | +--------> Ground
' +----------> Button 2
'----------------------------------------------------------------------
'
' Sony Playstation
' ~~~~~~~~~~~~~~~~
'
' The PSX controller is supported by the gamecon.c. Pinout of the PSX
' controller (compatible with DirectPadPro):
'
' +---------+---------+---------+
' 9 | o o x | o o o | o x x | 1 parallel
' \________|_________|________/ port pins
' | | | | | |
' | | | | | +--------> Clock --- (4)
' | | | | +------------> Select --- (3)
' | | | +---------------> Power --- (5-9)
' | | +------------------> Ground --- (18-25)
' | +-------------------------> Command --- (2)
' +----------------------------> Data --- (one of 10,11,12,13,15)
'
'----------------------------------------------------------------------
'Chip model
#chip tiny84a, 8
'I/O
#define o_up PORTA.4
#define o_dn PORTA.4
#define o_le PORTA.4
#define o_ri PORTA.4
#define o_f1 PORTA.4
#define o_f2 PORTA.4
#define i_dat PORTA.3
#define i_lat PORTA.3
#define i_clk PORTA.3
dir o_up out
dir o_dn out
dir o_le out
dir o_ri out
dir o_f1 out
dir o_f2 out
dir i_dat in
dir i_lat in
dir i_clk in
Startup:
'Main routine
Loop:
Wait 100 ms
'Jump back to the start of the program
goto Loop