Skip to content

Instantly share code, notes, and snippets.

View ped7g's full-sized avatar
💭
ZX Spectrum Next is here, panic!

Peter Ped Helcmanovsky ped7g

💭
ZX Spectrum Next is here, panic!
  • 7 Gods demo group
  • Prague
  • X @ped7g
View GitHub Profile
@ped7g
ped7g / Make Tap from assembly fix
Created July 29, 2020 07:36
fixed + cleaned up a bit source from Alexander
REAL_ORG = #3c51
DICT_BEGIN = #3c49
DATA_REG = 129
CONTROL_REG = 128
RTS_LOW = #16
RTS_HIGH = #56
MACRO CHECKSUM start?
opt push listoff ; disable listing while calculating checksum
.ptr = start?
@ped7g
ped7g / ECHO.asm
Created May 24, 2020 20:02
sjasmplus version of ZX Spectrum Next dot command "ECHO"
OUTPUT "ECHO"
ORG 8192
Start: ex de,hl
ld a,d
or e
ret z ; DE == 0, no pointer to arguments
Print: ld a,(de)
or a
ret z ; zero byte end of command line
cp 13
@ped7g
ped7g / limitHlValue.asm
Last active March 5, 2020 16:42
Z80 routine to clamp value in HL to -0x100 to +0x100 range
LimitHlValue:
; In: HL = value to be clamped to -0x100 .. +0x100
; Out: HL = clamped value
; Uses: A + flags
; (this is not mathematically correct, values 0x7F?? clamp to -0x100, for performance reasons)
ld a,h
inc a
sra a ; will be 0 for -256..+255 (+256 will get "clamped")
ret z
ld hl,0x100
@ped7g
ped7g / zx_next_detect_video_mode.asm
Created October 29, 2019 16:18
utility routines for ZX Spectrum Next (mostly to detect current video mode) (not tested properly yet)
; syntax for https://github.com/z00m128/sjasmplus/releases assembler
OPT --syntax=abfw --zxnext
;;----------------------------------------------------------------------------------------
;; reads nextreg in A into A
ReadNextReg:
; Input
; A = nextreg to read
; Output:
DEVICE ZXSPECTRUM48
OPT reset --zxnext=cspect --syntax=abfw
ORG $8000
start:
;; FIRST test: black border configured into default transparency fallback colour, inkmask 7
; black border
xor a
out (254),a
; configure the NextULA palette (inkmask 7, select ULA palette for write, display first pals, enable NextULA mode)
nextreg $42,$07 ,, $43,%0'000'0'0'0'1
@ped7g
ped7g / fixed_point_math_example_x86_64_linux.asm
Created March 15, 2018 00:45
x86_64 linux asm example of fixed-point arithmetic
; (C) [copyleft] 2018 Peter Helcmanovsky
; License: CC0 https://creativecommons.org/share-your-work/public-domain/cc0
;
; x86_64 linux asm example of fixed-point arithmetic
; (see https://en.wikipedia.org/wiki/Fixed-point_arithmetic)
;
; to build I'm using nasm and ld:
; nasm -f elf64 %f -l %n.lst -w+all; ld -b elf64-x86-64 -o %n %n.o
; (where %f is source file name and %n is just the main part w/o extension)
;