Descripción del contenido de la página

Un modo de impresión de juegos de caracteres de ocho bitios para ZX BASIC.



charset224 es una modalidad alternativa de impresión para el lenguaje ZX BASIC.

charset224 permite usar un juego de caracteres estándar de ocho bitios en lugar del original de ZX Spectrum. Incluye un juego de caracteres Latin1, aunque aún incompleto.

Instrucciones de uso

Doy por supuesto que estás familiarizado con ZX BASIC y GNU/Linux:

Para usar el módulo charset224 hay que usar el fichero print.modified_for_charset224.z80s en lugar del original de ZX BASIC, que es library-asm/print.asm.

Renombra print.asm como print_ORIGINAL.fs y copia print_charset224.z80s en library-asm/. Crea un enlace simbólico con el nombre original print.asm que apunte a print_charset224.z80s.

Ya puedes incluir charset224.zxbas en tus programas. Examina la fuente del programa de demostración.


La demo:

charset224 demo, page 1charset224 demo, page 2

Código fuente

' charset224.zxbas
' An addon for ZX BASIC (
' Version A-00-20140511

' This file is part of charset224
' (

' Copyright (C) 2014 Marcos Cruz (

' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 3 of the License, or
' (at your option) any later version.
' This program is distributed in the hope that it will be useful, but
' WITHOUT ANY WARRANTY; without even the implied warranty of
' General Public License for more details.
' You should have received a copy of the GNU General Public License
' along with this program; if not, see <>.

' --------------------------------------------------------------
' Description 

' This ZX BASIC file provides a sub called 'charset224'. It activates
' or deactivates a new printing mode. In the new mode, all 224 chars
' from 0x20 to 0xFF are printed as ordinary chars from the standard
' charset pointed by the CHARS system variable (no UDG, no block
' graphics, no tokens). Of course in order to use the new mode a
' proper 224-char font has to be in memory and CHARS has to be changed
' accordingly.

' The objective is to use a standard 8-bit character set (e.g.  Latin
' 1) in ZX BASIC programs.  This is very useful for programs in other
' languages than English, especially for programs that need a lot of
' text (text adventures or certain applications): No special notation
' or tricks are required in order to use standard non-ASCII chars into
' the texts the program will show at run-time.

' A 224-char font ocuppies 1792 bytes, and probably most of the chars
' will not be required by most programs, but the space of the unused
' chars can be used for graphics, data or even Z80 code.

' --------------------------------------------------------------
' Idea for an improved version

' A new printing mode to use the new font only for chars greater than
' 0x7E. This option would save 752 bytes. This mode would be useful
' for large programs that do not need a whole 255-bit new font design,
' but just need to add the missing standard non-ASCII chars to the
' ordinary ZX Spectrum font.

' --------------------------------------------------------------
' History

' 2014-05-06: First simple version. The parameter of the sub is the
' jump opcode required to hack the original <library-asm/print.asm>
' with. Two lines of code have to be previously and permanently
' modified in <library-asm/print.asm>.

' 2014-05-11: The code was rewritten and improved with a different
' approach: The original <library-asm/print.asm> has not to be
' previously modified, only a new label has to be added to it. All
' required changes are done by the sub.  Its parameter is just a flag.
' The program is renamed.

' --------------------------------------------------------------

#ifndef __LIBRARY_CHARSET224__

' Avoid recursive / multiple inclusion

#define __LIBRARY_CHARSET224__

sub fastcall charset224(flag as ubyte)

  ' This sub modifies the Z80 code of ZX BASIC's
  ' <library-asm/print.asm>, in order to change its behaviour.

  ' If flag=0
  '   the legacy ZX Spectrum charset printing mode is set
  '   (ordinary chars, UDG and block graphics are managed differently).
  '   This is the original behaviour of the printing routine.
  ' If flag<>0
  '   the modern 8-bit charset printing mode is set
  '   (all chars 20h-FFh are ordinary).



    ld hl,JUMP_IF_GREATER_THAN_80H ; address of the jump to be modified
    and a

    ; Set the legacy ZX Spectrum charset printing mode
    ld (HL),218  ; = 0xDA = Z80 'JP C'
    call READY
    ; original code
    add a, a  ; 1 byte
    ld l, a   ; 1 byte
    ld h, 0   ; 2 bytes

    ; Set the modern 8-bit charset printing mode
    ld (HL),195  ; = 0xC3 = Z80 'JP'
    call READY
    ; code to overwrite the original version with
    ld l, a   ; 1 byte
    ld h, 0   ; 2 bytes
    add hl,hl ; 1 byte

    local READY
    pop hl            ; get the source address from the stack
    ld de,__PRGRAPH0  ; destination address
    ld bc,4           ; count


end asm

end sub