prettybasic
An extended ZX Spectrum 48K ROM with syntax highlighting and basic formatting.
Color groups:
- letters
- digits
- functions
- operators
- flow operators (GO TO, GO SUB...RETURN, IF...THEN, FOR...NEXT)
- REM and its content
Formatting:
- colon (:) is now acting as a carriage return
- IF...THEN is multiline
Misc.:
- control codes (ASCII 00...31) are now hidden in the LIST mode (and HAVE to be shown in edit mode (CS+1), but they're not)
- contrast-aware dynamic palette
Bugs and todo:
- line numbers are being printed in the current INK color - there is a separate subroutine that prints the line numbers
- control codes (ASCII 00...31) must be visible in edit mode
Mostly to read the old BASIC games. They were written in the infamous style "squeeze everything in 9999 lines" and quite hard to read due to it. Below are examples compared side by side:
- The modification is based on the disassembly done by Dr Ian Logan & Dr Frank O’Hara
- The original procedure at the address 0x1937 was replaced with a new one 0x386E
- Zeus Z80 Assembler
Colors schemes are being calculated dynamically based on the value of PAPER, as this pseudocode is illustrating:
# address of the system register containing the current color
const uint16 ATTR_T = 23695
uint8 current_color
uint8 original_color
uint8 paper_color
function set_color(byte modifier){
current_color = PEEK(ATTR_T)
original_color = current_color
paper_color = bit_extract(current_color, 3-5)
paper_color = bit_right_shift(paper_color, 3)
current_color = current_color AND b11111000 AND paper_color XOR modifier
POKE (ATTR_T), current_color
}
function restore_color(){
POKE (ATTR_T), original_color
}
"ATTR T" is a system register containing the value of the color attribute to be written into the VRAM attribute area.
The system registers are basically the bytes in the RAM, and "ATTR T" has fixed address of 0x5C8F (decimal 23695).
ROM screen output routines are seemingly using "ATTR T" each time a character or a graphical primitive is to be drawn, thus writing in 0x5C8F is the fastest way to set the output color.
Address: 0x5C8F
#bit description
0 ink blue
1 ink red
2 ink green
3 paper blue
4 paper red
5 paper green
6 bright
7 flash
Examples of the dynamic palette:
ZX Spectrum and its firmware (ROM) are owned by AMSTRAD and their position on this matter is quite liberal:
- Users allowed to change the firmware if they want to
- Users allowed to distribute the ROM modified or not, as soon as it contains the original copyright message
- No one is allowed to sell the ROM, doesn't matter how many time and efforts they invested in modifications
- Whoever is distributing the ROM as a part of the illegal hardware, "nailing them up by the testicles using rusty nails" is strongly recommended (lol they have a whole Eastern Block of nails to rust)
- However, authors of emulators are allowed to charge customers for the code they produced (i.e. the emulator) even if the ROM included into distribution
- Guys from the forum http://zx-pk.ru :
- weiv
- AndTorp
- iceoflame
- Andrew771
- Alex Rider
- Andrew Owen