charset224

Priskribo de la ĉi-paĝa enhavo

8-bit-signara modalo por ZX BASIC.

Etikedoj:

Priskribo

charset224 estas alternativa print-modalo por la lingvo ZX BASIC.

charset224 ebligas uzi norman 8-bitan signaron anstataŭ tiu originala de ZX Spectrum. Signaro Latin1 estas inkludita, kvankam ankoraŭ nekompleta.

Uzo

Supozendas vi minimume regas na ZX BASIC kaj GNU/Linukson:

Por uzi charset224 vi devas anstataŭigi la dosieron library-asm/print.asm de ZX BASIC per print.modified_for_charset224.z80s.

Movu na print.asm al kaj kopiu na print_charset224.z80s al library-asm/. Poste kreu molan ligilon printn.asm cele al print_charset224.z80s.

Nun vi povas inkludi na charset224.zxbas en viaj programoj. Vidu la deman programon.

Ekranfotoj

La demo:

charset224 demo, page 1charset224 demo, page 2

Fontkodo

' charset224.zxbas
' An addon for ZX BASIC (http://zxbasic.net)
' Version A-00-20140511

' This file is part of charset224
' (http://programandala.net/en.program.charset224.html)

' Copyright (C) 2014 Marcos Cruz (programandala.net)

' 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
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
' 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 <http://gnu.org/licenses>.

' --------------------------------------------------------------
' 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).

asm

    proc

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

    local RESTORE_THE_ORIGINAL_CODE
RESTORE_THE_ORIGINAL_CODE:
    ; 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

    local MODIFY_THE_ORIGINAL_CODE
MODIFY_THE_ORIGINAL_CODE:
    ; 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
READY:
    pop hl            ; get the source address from the stack
    ld de,__PRGRAPH0  ; destination address
    ld bc,4           ; count
    ldir

    endp

end asm

end sub

#endif

Deŝutoj