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 / 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)
;
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 / 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:
@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 / 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 / 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 / flipULA.asm
Last active February 3, 2021 20:40
ZX Spectrum Next - ULA double buffering example
DEVICE ZXSPECTRUMNEXT
ORG $8000 ; this example does map Bank5/Bank7 ULA to $4000 (to use "pixelad" easily)
mainLoop:
call FlipULABuffers ; flip the buffer screen to visible screen and flip buffer
call drawDot
jr mainLoop
FlipULABuffers: ; Flip ULA/Alt ULA screen (double buffer ULA screen)
; ret ; uncomment to see effect of non-double-buffered running (blinking dots)
ld a,(ULABank) ; Get screen to display this frame
@ped7g
ped7g / flipULA2.asm
Last active October 12, 2020 22:47
ZX Spectrum Next - ULA double buffering example v2 (advanced techniques: DMA + custom IM1 interrupt)
DEFINE USE_DMA_TO_CLEAR_SCREEN ; comment out to get LDIR clear version
DEFINE USE_DOUBLE_BUFFERING ; comment out to see single-buffer redraw issues
DEVICE ZXSPECTRUMNEXT
BORDER MACRO color?
ld a,color?
out (254),a
ENDM
@ped7g
ped7g / color8vs9b.asm
Created October 27, 2020 02:34
ZX Spectrum Next - show how 8bit defined colors expand the two "BB" bits to full 9bit color definition
; show how 8-bit color values RRRGGGBB are being extended to full 9-bit definition
; displays blue squares with 8bit blue part 0, 1, 2, 3 (all possible blue shades in 8b)
; and under them the 9bit defined blues as %000, %011, %101, %111 (how 8b extends to 9b)
; assembling: sjasmplus color8vs9b.asm ( https://github.com/z00m128/sjasmplus )
DEVICE ZXSPECTRUMNEXT : OPT --syntax=abfw
ORG $8000
start:
di
ld a,7
; to assemble: sjasmplus asterisk_vs_exclamation_char.asm
DEVICE ZXSPECTRUM48,31999 : OPT --zxnext
ORG $8000
font:
ASSERT 0 == high(font) % 8 ; must reside at aligned-enough address to fit this
ds '!'*8,0 ; don't bother to define other chars, go to exclamation mark
dg ---##---
dg ---##---
dg ---##---