uGophy is a part of ZX-Uno project

This commit is contained in:
nihirash 2019-07-23 20:05:55 +03:00
parent 059bfd1243
commit b46d5f45ec
9 changed files with 368 additions and 1 deletions

View File

@ -3,4 +3,4 @@ All the files for ZX-Uno project repository:
http://zxuno.com
http://www.atc.us.es/svn/zxuno/
License is Creative Commons by SA, except the cores that has its own license
License is Creative Commons by SA, except the cores and ugophy(gopher browser) that has its own license

1
software/esprst/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
esprst

7
software/esprst/Makefile Normal file
View File

@ -0,0 +1,7 @@
all: esprst
esprst:
sjasmplus main.asm
clean:
rm esprst

66
software/esprst/main.asm Normal file
View File

@ -0,0 +1,66 @@
DEVICE ZXSPECTRUM48
org #2000
Start:
ld hl, init_txt
call putS
call uartBegin
ld hl, cmd_mode
call uartWriteStringZ
call wait
ld hl, cmd_rst
call uartWriteStringZ
call wait
call wait
ld hl, cmd_at
call uartWriteStringZ
wtlp:
call uartReadBlocking
call pushRing
ld hl,response_ok
call searchRing
cp 1
jr nz, wtlp
ld hl, fin
call putS
ret
wait:
ld b, 50
wlp:
halt
djnz wlp
ret
include "uart.asm"
include "ring.asm"
putS:
ld a, (hl)
or 0
ret z
push hl
rst #10
pop hl
inc hl
jr putS
init_txt defb ".EspRst v.0.1 (c) Nihirash",13,"This tool resets esp-chip",13,0
fin defb "WiFi module ready to work", 13, 0
cmd_mode defb "+++", 0
cmd_rst defb "AT+RST", 13, 10, 0
cmd_at defb "AT", 13, 10, 0
response_ok defb "OK", 13, 10, 0
SAVEBIN "esprst", Start, $ - Start

60
software/esprst/ring.asm Normal file
View File

@ -0,0 +1,60 @@
; Pushes A to ring buffer
pushRing
push af
ld b, 32
ld hl, ring_buffer + 1
ld de, ring_buffer
ringL
ld a, (hl)
ld (de), a
inc hl
inc de
djnz ringL
pop af
ld hl, ring_buffer + 31
ld (hl), a
ret
; HL - Compare string(null terminated)
; A - 0 NOT Found
; 1 Found
searchRing:
ld b, 0
push hl
serlp:
ld a, (hl)
inc hl
inc b
and a
jp nz, serlp
dec b
pop hl
push bc
push hl
SRWork:
pop hl
ld de, ring_buffer + 32
srcLp
dec de
djnz srcLp
pop bc
ringCmpLp
push bc
push af
ld a, (de)
ld b, a
pop af
ld a, (hl)
cp b
pop bc
ld a, 0
ret nz
inc de
inc hl
djnz ringCmpLp
ld a, 1
ret
ring_buffer dup 33
defb 0
edup

194
software/esprst/uart.asm Normal file
View File

@ -0,0 +1,194 @@
UART_DATA_REG = #c6
UART_STAT_REG = #c7
UART_BYTE_RECIVED = #80
UART_BYTE_SENT = #40
ZXUNO_ADDR = #FC3B
ZXUNO_REG = #FD3B
; Enable UART
; Cleaning all flags by reading UART regs
; Wastes AF and BC
uartBegin:
ld bc, ZXUNO_ADDR
ld a, UART_STAT_REG
out (c), a
ld bc, ZXUNO_REG
in A, (c)
ld bc, ZXUNO_ADDR
ld a, UART_DATA_REG
out (c), a
ld bc, ZXUNO_REG
in A, (c)
ret
; Pushes to UART zero-terminated string
; HL - string poiner
uartWriteStringZ:
ld a, (hl)
and a
ret z
push hl
call uartWriteByte
pop hl
inc hl
jp uartWriteStringZ
; Blocking read one byte
uartReadBlocking:
call uartRead
push af
ld a, 1
cp b
jr z, urb
pop af
ret nz
jp uartReadBlocking
urb:
pop af
ret
; Write single byte to UART
; A - byte to write
; BC will be wasted
uartWriteByte:
push af
ld bc, ZXUNO_ADDR
ld a, UART_STAT_REG
out (c), a
waitWriteReady:
ld bc, ZXUNO_REG
in A, (c)
and UART_BYTE_RECIVED
jr nz, is_recvF
checkSent:
ld bc, ZXUNO_REG
in A, (c)
and UART_BYTE_SENT
jr nz, checkSent
ld bc, ZXUNO_ADDR
ld a, UART_DATA_REG
out (c), a
ld bc, ZXUNO_REG
pop af
out (c), a
ret
is_recvF:
push af
push hl
ld hl, is_recv
ld a, 1
ld (hl), a
pop hl
pop af
jr checkSent
; Is data avail in UART
; NZ - Data Presents
; Z - Data absent
uartAvail:
ld a, (is_recv)
and 1
ret nz
ld a, (poked_byte)
and 1
ret nz
call uartRead
push af
ld a, b
and 1
jr z, noneData
pop af
push af
ld hl, byte_buff
ld (hl), a
ld hl, poked_byte
ld a, 1
ld (hl), a
pop af
ld b, a
ld a, 1
or a
ld a, b
ret
noneData:
pop bc
xor a
ret
; Read byte from UART
; A: byte
; B:
; 1 - Was read
; 0 - Nothing to read
uartRead:
ld a, (poked_byte)
and 1
jr nz, retBuff
ld a, (is_recv)
and 1
jr nz, recvRet
ld bc, ZXUNO_ADDR
ld a, UART_STAT_REG
out (c), a
ld bc, ZXUNO_REG
in a, (c)
and UART_BYTE_RECIVED
jr nz, retReadByte
ld b, 0
ret
retReadByte:
ld a, 0
ld (poked_byte), a
ld (is_recv), a
ld bc, ZXUNO_ADDR
ld a, UART_DATA_REG
out (c), a
ld bc, ZXUNO_REG
in a, (c)
ld b, 1
ret
recvRet:
ld bc, ZXUNO_ADDR
ld a, UART_DATA_REG
out (c),a
ld bc, ZXUNO_REG
in a, (c)
ld hl, is_recv
ld (hl), 0
ld hl, poked_byte
ld (hl), 0
ld b, 1
ret
retBuff
ld a, 0
ld (poked_byte), a
ld a, (byte_buff)
ld b, 1
ret
poked_byte defb 0
byte_buff defb 0
is_recv defb 0

3
software/iwconfig/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.bin
*.def
IWCONFIG

View File

@ -0,0 +1,7 @@
all: iwconfig
iwconfig: iwconfig.c
zcc +zx -vn -startup=30 -clib=new iwconfig.c -SO3 -o iwconfig -subtype=dot -create-app
clean:
rm *.bin *.def IWCONFIG

View File

@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdarg.h>
#include <arch/zx/esxdos.h>
#include <string.h>
char ssid[80];
char pass[80];
int i;
int file;
int main(int argc, char **argv)
{
printf("IWConfig by nihirash v.0.1\nWireless interface configurator\n");
if (argc < 3) {
printf(".iwconfig SSID PASSWD\n");
return 0;
}
for (int i=0;i<80;i++) {
ssid[i] = pass[i] = 0;
}
strcpy(ssid, argv[1]);
strcpy(pass, argv[2]);
file = esx_f_open("/sys/config/iw.cfg", ESX_MODE_WRITE | ESX_MODE_OPEN_CREAT_TRUNC);
esx_f_write(file, ssid, 80);
esx_f_write(file, pass, 80);
esx_f_close(file);
return 0;
}