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
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 / 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 ---##---
@ped7g
ped7g / omega_fades.asm
Last active January 12, 2021 19:12
ZX Spectrum fade-in/fade-out effects using attributes, focusing on small code size (no tables used)
; Authors: Omega, Ped7g, Baze ; (C) 2021 ; license: https://opensource.org/licenses/MIT
; Z80 assembly, syntax for sjasmplus: https://github.com/z00m128/sjasmplus
; to assemble run: sjasmplus omega_fades.asm
OPT --syntax=abf
DEVICE ZXSPECTRUM48,31999
ORG $8000
;------------------------------------------------------------------------------
; ULA attributes "fade out" effect, going through PAPER/INK values,
; decrements them (individually) by 1 every iteration (call of routine)
@ped7g
ped7g / omega_fades_2.asm
Last active February 3, 2021 20:38
ZX Spectrum fade-in/fade-out effects using attributes, focusing on small code size (second version)
; Authors: Omega, Ped7g, Baze ; (C) 2021 ; license: https://opensource.org/licenses/MIT
; Z80 assembly, syntax for sjasmplus: https://github.com/z00m128/sjasmplus
; to assemble run: sjasmplus omega_fades_2.asm
OPT --syntax=abf
DEVICE ZXSPECTRUM48,31999
ORG $8000
; uncomment and set to available SCR file to run the effect on ZX screen image (6912 bytes)
; DEFINE SCR_FILE "diver - Mercenary 4. The Heaven's Devil (2014) (Forever 2014 Olympic Edition, 1).scr"