├── example ├── nes │ ├── font.pal │ ├── mario.pal │ ├── demo.nes │ ├── font.spr │ ├── mario.spr │ ├── higueul_make.txt │ └── main.egl ├── SNES │ ├── DATA │ │ ├── randi.pal │ │ └── randi.spr │ ├── SNDK │ │ ├── fontm.pal │ │ ├── fontm.spr │ │ ├── fontm2.pal │ │ ├── fontm3.pal │ │ ├── header.egl │ │ ├── macro.egl │ │ ├── VBlank.egl │ │ ├── crt0.egl │ │ ├── Init.egl │ │ ├── Print.egl │ │ ├── Sprite.egl │ │ └── bss_define.egl │ ├── higueul_make.txt │ ├── data.egl │ └── main.egl ├── z80 │ ├── higueul_make.txt │ ├── out.asm │ ├── main.egl │ └── demo.bin ├── gametank │ ├── higueul_make.txt │ ├── demo.mlb │ ├── main.egl │ └── out.asm └── test.egl ├── highlighting ├── geany │ ├── filedefs │ │ ├── filetypes.sh │ │ ├── filetypes.ruby │ │ ├── filetypes.html │ │ ├── filetypes.vhdl │ │ ├── filetypes.c │ │ ├── filetypes.README │ │ ├── filetypes.Eagle.conf │ │ ├── filetypes.WIZ.conf │ │ ├── filetypes.Sm.conf │ │ ├── filetypes.C64.conf │ │ ├── filetypes.Nes.conf │ │ ├── filetypes.Zng.conf │ │ ├── filetypes.SPC.conf │ │ ├── filetypes.Ast.conf │ │ ├── filetypes.asm │ │ ├── filetypes.PCE.conf │ │ ├── filetypes.MD.conf │ │ ├── filetypes.Cps1.conf │ │ ├── filetypes.F3.conf │ │ ├── filetypes.Sng.conf │ │ └── filetypes.common │ └── filetype_extensions.conf ├── Higueul-language-VSC │ ├── .gitignore │ ├── .gitattributes │ ├── .vscodeignore │ ├── README.md │ ├── CHANGELOG.md │ ├── .vscode │ │ └── launch.json │ ├── language-configuration.json │ ├── package.json │ ├── LICENSE │ ├── vsc-extension-quickstart.md │ └── syntaxes │ │ └── higueul.tmLanguage.json └── vscode │ ├── run.sh │ ├── higueul-highlighter-1.0.0.vsix │ ├── language-configuration.json │ ├── syntaxes │ └── higueul.tmLanguage.json │ ├── themes │ └── higueul-color-theme.json │ └── package.json ├── make.sh ├── src ├── Eagle_bin_80286.cpp ├── Eagle_bin_HuC6280.cpp ├── Eagle_asm_HuC6280.cpp ├── CPU_Z80_asm.cpp ├── Eagle_asm_80286.cpp ├── CPU_Z80.hpp ├── Eagle_struct.hpp ├── Eagle_enum.hpp ├── Eagle_asm.cpp ├── main.cpp ├── rmake.cpp ├── Eagle_asm_AltairX.cpp ├── Eagle.hpp ├── constant_folding.cpp ├── Eagle_parser.cpp ├── Eagle_asm_z80.cpp └── Eagle.cpp ├── LICENSE ├── README.md ├── Higueul.cbp └── makefile /example/nes/font.pal: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /example/nes/mario.pal: -------------------------------------------------------------------------------- 1 | ' -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix -------------------------------------------------------------------------------- /highlighting/vscode/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | vsce package 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/nes/demo.nes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/nes/demo.nes -------------------------------------------------------------------------------- /example/nes/font.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/nes/font.spr -------------------------------------------------------------------------------- /example/nes/mario.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/nes/mario.spr -------------------------------------------------------------------------------- /make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | /usr/local/SDK/tools/cbp2make -in Higueul.cbp -out makefile 3 | 4 | -------------------------------------------------------------------------------- /example/SNES/DATA/randi.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/DATA/randi.pal -------------------------------------------------------------------------------- /example/SNES/DATA/randi.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/DATA/randi.spr -------------------------------------------------------------------------------- /example/SNES/SNDK/fontm.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/SNDK/fontm.pal -------------------------------------------------------------------------------- /example/SNES/SNDK/fontm.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/SNDK/fontm.spr -------------------------------------------------------------------------------- /example/SNES/SNDK/fontm2.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/SNDK/fontm2.pal -------------------------------------------------------------------------------- /example/SNES/SNDK/fontm3.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/example/SNES/SNDK/fontm3.pal -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.ruby: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | EX_00_LB=_Exécuter 3 | EX_00_CM=irb %f 4 | EX_00_WD= 5 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /highlighting/vscode/higueul-highlighter-1.0.0.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kannagi/Higueul/HEAD/highlighting/vscode/higueul-highlighter-1.0.0.vsix -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.html: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM= 4 | FT_00_WD= 5 | EX_00_LB=_Exécuter 6 | EX_00_CM=firefox %f 7 | EX_00_WD= 8 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.vhdl: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB= 3 | FT_00_CM=bash compile.sh 4 | FT_00_WD= 5 | EX_00_LB=_Exécuter 6 | EX_00_CM=gtkwave prg.vcd 7 | EX_00_WD= 8 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.c: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=gcc main.c -lSDL -o main 4 | FT_00_WD= 5 | EX_00_LB=_Exécuter 6 | EX_00_CM=./main rom.md 0 2 7 | EX_00_WD= 8 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/README.md: -------------------------------------------------------------------------------- 1 | # Higueul Language 2 | 3 | ## Features 4 | 5 | Basic syntax highlighting for Higueul Language. 6 | 7 | ## Release Notes 8 | 9 | ### 1.0.0 10 | 11 | Initial release 12 | -------------------------------------------------------------------------------- /example/z80/higueul_make.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | #options:-debug -asm 4 | #options:-cycle 5 | #cmd_execute: pwd 6 | options:-z80 -asm -mesen 7 | 8 | 9 | #file game 10 | add_file:main.egl; 11 | 12 | 13 | compiler_run:demo.bin 14 | 15 | -------------------------------------------------------------------------------- /example/nes/higueul_make.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | #options:-debug -asm 4 | #options:-cycle 5 | #cmd_execute: pwd 6 | options:-6502 -asm -mesen 7 | 8 | 9 | #file game 10 | add_file:main.egl; 11 | 12 | 13 | compiler_run:demo.nes 14 | 15 | -------------------------------------------------------------------------------- /example/gametank/higueul_make.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | #options:-debug -asm 4 | #options:-cycle 5 | #cmd_execute: pwd 6 | options:-65C02 -asm -mesen 7 | 8 | 9 | #file game 10 | add_file:main.egl; 11 | 12 | 13 | compiler_run:demo.bin 14 | 15 | -------------------------------------------------------------------------------- /src/Eagle_bin_80286.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | void Eagle::bin_80286() 13 | { 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.README: -------------------------------------------------------------------------------- 1 | Copy files from /usr/share/geany to this directory to overwrite them. To use the defaults, just delete the file in this directory. 2 | For more information read the documentation (in /usr/share/doc/geany-1.22/html/index.html or visit http://www.geany.org/). -------------------------------------------------------------------------------- /src/Eagle_bin_HuC6280.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "Eagle.hpp" 13 | 14 | void Eagle::bin_HuC6280() 15 | { 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "altairx-asm" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /example/gametank/demo.mlb: -------------------------------------------------------------------------------- 1 | PcePrgRom:4000-4021:_start 2 | PcePrgRom:4022-4025:VBlank 3 | PcePrgRom:4026-4026:IRQ 4 | PcePrgRom:4027-40CA:main 5 | PcePrgRom:40CB-40D7:waitVBlank 6 | PcePrgRom:40D8-40FC:BlitRectangle 7 | PceWorkRam:600:FRAME_FLAG 8 | PceWorkRam:601:rectX 9 | PceWorkRam:602:rectY 10 | PceWorkRam:603:velX 11 | PceWorkRam:604:velY 12 | PceWorkRam:00-7F:SPM 13 | PceWorkRam:80-D0:LIB 14 | PceWorkRam:E0-EF:FUNCLIB 15 | PceWorkRam:F0-FF:FUNCSPM 16 | -------------------------------------------------------------------------------- /highlighting/vscode/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "//", 4 | "blockComment": ["/*", "*/"] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "autoClosingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["\"", "\""] 16 | ], 17 | "surroundingPairs": [ 18 | ["{", "}"], 19 | ["[", "]"], 20 | ["(", ")"], 21 | ["\"", "\""], 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /example/SNES/higueul_make.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | #options:-debug -asm 4 | 5 | #cmd_execute: pwd 6 | 7 | 8 | #file crt SDK 9 | add_file: SNDK/bss_define.egl; SNDK/header.egl; SNDK/macro.egl; 10 | add_file: SNDK/crt0.egl; 11 | 12 | 13 | #file game 14 | add_file:main.egl; 15 | 16 | #add_folder:src; 17 | 18 | 19 | #file SNDK 20 | add_file: SNDK/VBlank.egl; SNDK/Sprite.egl; SNDK/Print.egl; 21 | add_file: SNDK/Init.egl; 22 | 23 | #DATA 24 | add_file:data.egl; 25 | 26 | compiler_run:-65816 27 | 28 | -------------------------------------------------------------------------------- /example/SNES/data.egl: -------------------------------------------------------------------------------- 1 | 2 | 3 | SNES_BANK 2 4 | 5 | sprite_data: 6 | .incbin "misc-01.spr" 7 | 8 | pal_data: 9 | .incbin "misc-01.pal" 10 | 11 | RANDI_PAL: 12 | .incbin "DATA/randi.pal" 13 | 14 | 15 | SNES_BANK 3 16 | RANDI_SPR: 17 | .incbin "DATA/randi.spr" 18 | SNES_BANK 4 19 | 20 | SNES_BANK 5 21 | 22 | SNES_BANK 6 23 | 24 | SNES_BANK 7 25 | 26 | SNES_BANK 8 27 | 28 | SNES_BANK 9 29 | 30 | SNES_BANK 10 31 | 32 | SNES_BANK 11 33 | 34 | SNES_BANK 12 35 | 36 | SNES_BANK 13 37 | 38 | SNES_BANK 14 39 | 40 | SNES_BANK 15 41 | .org 0x80000 42 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Eagle.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=./higueulc 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=snes9x out.smc 10 | EX_00_WD= 11 | 12 | 13 | [styling=C] 14 | 15 | 16 | 17 | 18 | [keywords] 19 | primary=uint8 uint16 uint32 uint64 int8 int16 int32 int64 float16 float32 float64 void register spm stack lib asm 20 | secondary=if else do while loop jump call return proc func funcreg funcspm funclib funsp bss org code rodata end define macro funcmap spmmap macro endmacro incbin 21 | 22 | [settings] 23 | extension=egl 24 | 25 | lexer_filetype=C 26 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.WIZ.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash compile.sh 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=snes9x-gtk -displayframerate -displaykeypress main.sfc 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | [styling=C] 17 | 18 | [keywords] 19 | 20 | primary=in inline const func if else while do for extern let goto break continue var u8 u16 i8 i16 far 21 | secondary=import embed struct union enum 22 | 23 | 24 | [settings] 25 | extension=wiz 26 | 27 | lexer_filetype=C 28 | 29 | # multiline comments 30 | comment_open=/* 31 | comment_close=*/ 32 | -------------------------------------------------------------------------------- /src/Eagle_asm_HuC6280.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "Eagle.hpp" 13 | 14 | //static void asm_address(const EAGLE_VARIABLE &src,std::string &labelp,const std::string &pregister,std::string &srcvalue,std::string &str_code); 15 | 16 | void Eagle::asm_bru_Huc6280(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 17 | { 18 | 19 | } 20 | 21 | void Eagle::asm_alu_Huc6280(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 22 | { 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": ";" 5 | }, 6 | // symbols used as brackets 7 | "brackets": [ 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | // symbols that are auto closed when typing 12 | "autoClosingPairs": [ 13 | ["{", "}"], 14 | ["[", "]"], 15 | ["(", ")"], 16 | ["\"", "\""] 17 | ], 18 | // symbols that can be used to surround a selection 19 | "surroundingPairs": [ 20 | ["{", "}"], 21 | ["[", "]"], 22 | ["(", ")"], 23 | ["\"", "\""], 24 | ] 25 | } -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "higueul-language", 3 | "displayName": "Higueul language", 4 | "description": "Basic Syntax Highlighting for Higueul language", 5 | "version": "1.0.0", 6 | "engines": { 7 | "vscode": "^1.50.0" 8 | }, 9 | "categories": [ 10 | "Programming Languages" 11 | ], 12 | "repository": { 13 | "url": "https://github.com/Alairion/AltairX-ASM-VSC.git" 14 | }, 15 | "contributes": { 16 | "languages": [{ 17 | "id": "higueullanguage", 18 | "aliases": ["Higueul language", "higueullanguage"], 19 | "extensions": [".egl"], 20 | "configuration": "./language-configuration.json" 21 | }], 22 | "grammars": [{ 23 | "language": "higueullanguage", 24 | "scopeName": "source.higueul", 25 | "path": "./syntaxes/higueul.tmLanguage.json" 26 | }] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Sm.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash /usr/local/SDK/ASM/sms.sh main 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=mednafen main.sms 10 | EX_00_WD= 11 | 12 | [styling=ASM] 13 | 14 | 15 | 16 | 17 | [keywords] 18 | # all items must be in one line 19 | # this is by default a very simple instruction set; not of Intel or so 20 | instructions=adc add and bit call ccf cp cpd cpdr cpi cpir cpl daa dec di djnz ei ex exx halt im in inc inc ind indr ini inir jp jr ld ldd lddr ldr ldir neg nop or otdr otir out outd outi pop push res ret retn rl rla rlc rlca rld rr rra rrc rrca rrd rst sbc scf set sla sra srl sub xor 21 | registers=a b c d e f h l ix iy sp pc hl af bc de 22 | directives=.define .section .bank .org .include .ends .db .macro .endm .memorymap .endme .rombankmap .endro 23 | 24 | 25 | [settings] 26 | extension=sm 27 | 28 | lexer_filetype=ASM 29 | 30 | # multiline comments 31 | comment_open=/* 32 | comment_close=*/ 33 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.C64.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=/home/kannagi/Documents/SDK/SNES/bin/commodore.sh main 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=Frodo main.c64 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | [styling=ASM] 17 | 18 | 19 | 20 | 21 | [keywords] 22 | # all items must be in one line 23 | # this is by default a very simple instruction set; not of Intel or so 24 | instructions=adc and asl bcc blt bcs bge beq bit bra brk brl bvc bvs bpl bmi bne beq cmp cpx cpy cop clc cld cli clv dec dea dex dey eor inc ina inx iny jmp jml jsr jsl lda ldy ldx lsr mvn nop ora pea pei per phb phd phk php phx phy pla pha plx ply rep rts rtl rti sec sei sep sta stx sty stz sbc tay tax txa txy tyx tya tax wai xba xce 25 | registers= 26 | directives=.define .section .bank .org .include .ends .db .macro .endm .memorymap 27 | 28 | 29 | [settings] 30 | extension=a64 31 | 32 | lexer_filetype=ASM 33 | 34 | # multiline comments 35 | comment_open=/* 36 | comment_close=*/ 37 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Nes.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash /usr/local/SDK/ASM/nes.sh main 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=mednafen main.nes 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=fceux main.nes 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | [styling=ASM] 17 | 18 | 19 | 20 | 21 | [keywords] 22 | # all items must be in one line 23 | # this is by default a very simple instruction set; not of Intel or so 24 | instructions=adc and asl bcc blt bcs bge beq bit bra brk brl bvc bvs bpl bmi bne beq cmp cpx cpy cop clc cld cli clv dec dea dex dey eor inc ina inx iny jmp jml jsr jsl lda ldy ldx lsr mvn nop ora pea pei per phb phd phk php phx phy pla pha plx ply rep rts rtl rti sec sei sep sta stx sty stz sbc tay tax txa txy tyx tya tax wai xba xce 25 | registers=x y 26 | directives=.define .section .bank .org .include .ends .db .macro .endm .memorymap 27 | 28 | 29 | [settings] 30 | extension=ans 31 | 32 | lexer_filetype=ASM 33 | 34 | # multiline comments 35 | comment_open=/* 36 | comment_close=*/ 37 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024 Alexy Pellegrini 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Zng.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=/usr/local/SDK/ASM/vasmz80_mot -Fbin %f -o 052-m1.bin & zip -1 ssideki *.bin 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=gngeo --rompath=/home/kannagi/Documents/RetroProg/Console/NeoGeo/SDK/bin/ ssideki 10 | EX_00_WD= 11 | 12 | 13 | [styling=ASM] 14 | 15 | 16 | 17 | 18 | [keywords] 19 | # all items must be in one line 20 | # this is by default a very simple instruction set; not of Intel or so 21 | instructions=adc add and bit call ccf cp cpd cpdr cpi cpir cpl daa dec di djnz ei ex exx halt im in inc inc ind indr ini inir jp jr ld ldd lddr ldr ldir neg nop or otdr otir out outd outi pop push res ret retn rl rla rlc rlca rld rr rra rrc rrca rrd rst reti sbc scf set sla sra srl sub xor 22 | registers=a b c d e f h l ix iy sp pc hl af bc de 23 | directives=org rorg include macro endm equ dc dc.b dc.w dc.l 24 | 25 | 26 | [settings] 27 | extension=zng 28 | 29 | lexer_filetype=ASM 30 | 31 | # multiline comments 32 | comment_open=/* 33 | comment_close=*/ 34 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.SPC.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash /usr/local/SDK/ASM/spc.sh driver && bash /usr/local/SDK/ASM/snes.sh main 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=zsnes main.smc 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=snes9x-gtk -displayframerate -displaykeypress main.smc 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | [styling=ASM] 17 | 18 | 19 | 20 | 21 | [keywords] 22 | # all items must be in one line 23 | # this is by default a very simple instruction set; not of Intel or so 24 | instructions=mov adc sbc cmp and or eor asl movw incw dew addw subw cmpw mul div daa das bra beq bne bcs bcc bvs bvc bmi bpl bbs bbc cbne dbnz clrc dec inc jmp call pcall tcall brk lsr ret reti push pop set1 clr1 tset1 tclr1 and1 or1 eor1 mov1 setc notc clrv setpei di nop sleepstoprol ror xcn 25 | registers=a x y ya sp psw 26 | directives=.define .section .bank .org .include .ends .db .dw .macro .endm .memorymap 27 | 28 | 29 | [settings] 30 | extension=aspc 31 | 32 | lexer_filetype=ASM 33 | 34 | # multiline comments 35 | comment_open=/* 36 | comment_close=*/ 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kannagi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Ast.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=/usr/local/SDK/ASM/vasmm68k_mot -m68000 -no-opt -devpac -Ftos -o game.tos "%f" 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM= 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=hatari game.tos 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | [styling=ASM] 17 | 18 | 19 | 20 | 21 | [keywords] 22 | # all items must be in one line 23 | # this is by default a very simple instruction set; not of Intel or so 24 | instructions=move move.b move.w move.l lea clr clr.b clr.w clr.l movem movem.b movem.w movem.l dbra addi addi.b addi.w addi.l neg neg.b neg.w neg.l nop mulu cmp bra btst jsr beq bne bpl bmi ble bge lsr lsr.b lsr.w lsr.l lsl lsl.b lsl.w lsl.l ori ori.b ori.w ori.l jmp btst btst.b btst.w btst.l add add.b add.w add.l cmp.b cmp.w cmp.l sub sub.b sub.w sub.l rte rts tst tst.b tst.w tst.l 25 | registers=a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 sp pc usp ssp 26 | directives=org include incbin macro endm equ dc dc.b dc.w dc.l 27 | 28 | 29 | [settings] 30 | extension=ast 31 | 32 | lexer_filetype=ASM 33 | 34 | # multiline comments 35 | comment_open=/* 36 | comment_close=*/ 37 | -------------------------------------------------------------------------------- /src/CPU_Z80_asm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | void Eagle::asm_bru_z80(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 13 | { 14 | 15 | } 16 | 17 | void Eagle::asm_call_jump_z80(const EAGLE_VARIABLE &src,int ninst,int type) 18 | { 19 | 20 | } 21 | 22 | void Eagle::asm_return_z80(const EAGLE_VARIABLE &ret,bool retvoid) 23 | { 24 | 25 | } 26 | 27 | void Eagle::asm_alu_z80(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 28 | { 29 | std::string mnemonic; 30 | 31 | if(operator1 == '+') 32 | mnemonic = "add "; 33 | 34 | if(operator1 == '-') 35 | mnemonic = "sub "; 36 | 37 | if(operator1 == '&') 38 | mnemonic = "and "; 39 | 40 | if(operator1 == '|') 41 | mnemonic = "or "; 42 | 43 | if(operator1 == '^') 44 | mnemonic = "xor "; 45 | 46 | if(operator1 == '<') 47 | mnemonic = "shl "; 48 | 49 | if(operator1 == '>') 50 | mnemonic = "shr "; 51 | 52 | this->text_code += mnemonic + "\n"; 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.asm: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash /usr/local/SDK/ASM/snes.sh main 4 | FT_00_WD= 5 | EX_01_LB=Debug NG 6 | EX_01_CM=zsnes main.smc 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=bash execute.sh 10 | EX_00_WD= 11 | 12 | FT_01_LB=Neo geo 13 | FT_01_CM=cd .. && bash compile.sh 14 | FT_01_WD= 15 | 16 | FT_02_LB=default 17 | FT_02_CM=bash compile.sh 18 | FT_02_WD= 19 | 20 | [styling] 21 | 22 | 23 | [keywords] 24 | # all items must be in one line 25 | # this is by default a very simple instruction set; not of Intel or so 26 | instructions=adc and asl bcc blt bcs bge beq bit bra brk brl bvc bvs bpl bmi bne beq cmp cpx cpy cop clc cld cli clv dec dea dex dey eor inc ina inx iny jmp jml jsr jsl lda ldy ldx lsr mvn nop ora pea pei per phb phd phk php phx phy pla pha plx ply rep rts rtl rti sec sei sep sta stx sty stz sbc tay tax txa txy tyx tya tax wai xba xce txs tcd tsx plb plp pld lda.b lda.w ldy.b ldy.w ldx.b ldx.w 27 | registers=x y 28 | directives=.define .section .bank .org .include .ends .endst .ende .enum .db .dw db dw dsb dsw .macro .endm .memorymap .incbin .struct instanceof 29 | 30 | [settings] 31 | extension=asm 32 | 33 | # multiline comments 34 | comment_open=/* 35 | comment_close=*/ 36 | -------------------------------------------------------------------------------- /src/Eagle_asm_80286.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | void Eagle::asm_bru_80186(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 13 | { 14 | 15 | } 16 | 17 | void Eagle::asm_call_jump_80186(const EAGLE_VARIABLE &src,int ninst,int type) 18 | { 19 | 20 | } 21 | 22 | void Eagle::asm_return_80186(const EAGLE_VARIABLE &ret,bool retvoid) 23 | { 24 | 25 | } 26 | 27 | void Eagle::asm_alu_80186(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 28 | { 29 | std::string mnemonic; 30 | 31 | if(operator1 == '+') 32 | mnemonic = "add "; 33 | 34 | if(operator1 == '-') 35 | mnemonic = "sub "; 36 | 37 | if(operator1 == '&') 38 | mnemonic = "and "; 39 | 40 | if(operator1 == '|') 41 | mnemonic = "or "; 42 | 43 | if(operator1 == '^') 44 | mnemonic = "xor "; 45 | 46 | if(operator1 == '<') 47 | mnemonic = "shl "; 48 | 49 | if(operator1 == '>') 50 | mnemonic = "shr "; 51 | 52 | this->text_code += mnemonic + "\n"; 53 | } 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /example/SNES/SNDK/header.egl: -------------------------------------------------------------------------------- 1 | 2 | .macro SNES_HEADER 3 | //ROM Header 4 | .data.s "SNES SDK DEMO "; 5 | // "1234567890123456789" 6 | .data.b 0x30; //0x20 2.68 MHz / 0x30 3.58 MHz 7 | .data.b 0x00; //ROM only 8 | .data.b 0x09; //ROM size 1<>8 66 | ld a,(2) 67 | ld b,8 68 | sra a,b 69 | ld (4),a 70 | ;res = testb <<8 71 | ld a,(2) 72 | ld b,8 73 | sla a,b 74 | ld (4),a 75 | ;if test & 3 76 | cp 77 | jp .label_0 78 | ;else 79 | bra .label_1 80 | .label_0: 81 | .label_1: 82 | .label_b2: 83 | .label_2: 84 | ;while 1 == 1 85 | cp 86 | jp .label_b2 87 | ..end 88 | .org $800 89 | -------------------------------------------------------------------------------- /src/CPU_Z80.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | 5 | 6 | 7 | // Types ----------------------------------------------------------------------- 8 | 9 | // EagleZ80 - assembly code generation for Z80 10 | class CPU_Z80 { 11 | public: 12 | CPU_Z80(void); 13 | 14 | // initialize the Z80 translation engine. Resets all the internal states. 15 | void initialize(void); 16 | 17 | // asm_return_z80 translates a return operation 18 | std::string asm_return(const EAGLE_VARIABLE &ret, bool retvoid); 19 | 20 | // asm_alu_z80 translates an ALU operation 21 | std::string asm_alu(const EAGLE_VARIABLE &dst, 22 | const EAGLE_VARIABLE &src1, 23 | const EAGLE_VARIABLE &src2, 24 | const char operator1, 25 | const char operator2); 26 | 27 | // asm_bru_z80 translates a local control structures, IF, WHILE, DO etc. 28 | std::string asm_bru(const EAGLE_VARIABLE &src1, 29 | const EAGLE_VARIABLE &src2, 30 | const char operator1, 31 | const char operator2, 32 | int type, 33 | int clabel, 34 | int &ilabel); 35 | 36 | // asm_call_jump_z80 translates a CALL or JMP operation 37 | std::string asm_call_jump(const EAGLE_VARIABLE &var, 38 | int narg, 39 | int type, 40 | std::string &labelcall); 41 | 42 | void asm_do_else(void); 43 | 44 | private: 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.MD.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=/usr/local/SDK/ASM/vasmm68k_mot -Fbin -m68000 main.mds -o rom.md 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=gens rom.md 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=gens rom.md 10 | EX_00_WD= 11 | 12 | 13 | 14 | [styling=ASM] 15 | 16 | 17 | 18 | 19 | [keywords] 20 | # all items must be in one line 21 | # this is by default a very simple instruction set; not of Intel or so 22 | instructions=asl asl.b asl.w asl.l move move.b move.w move.l lea lea.b lea.w lea.l clr clr.b clr.w clr.l movem movem.b movem.w movem.l mulu mulu.b mulu.w mulu.l dbra add add.b add.w add.l addi addi.b addi.w addi.l and and.b and.w and.l andi andi.b andi.w andi.l neg neg.b neg.w neg.l nop mulu cmp bra btst jsr beq bne bpl bmi ble bge lsr lsr.b lsr.w lsr.l lsl lsl.b lsl.w lsl.l or or.b or.w or.l ori ori.b ori.w ori.l jmp btst btst.b btst.w btst.l add add.b add.w add.l cmp cmp.b cmp.w cmp.l sub sub.b sub.w sub.l rte rts tst tst.b tst.w tst.l subi subi.b subi.w subi.l cmpi cmpi.b cmpi.w cmpi.l st 23 | registers=a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 sp pc usp ssp 24 | directives=org include incbin macro endm equ dc dc.b dc.w dc.l 25 | 26 | 27 | [settings] 28 | extension=mds 29 | 30 | lexer_filetype=ASM 31 | 32 | # multiline comments 33 | comment_single=; 34 | 35 | -------------------------------------------------------------------------------- /example/z80/main.egl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | .map.func 0x200 6 | .map.funcspm 0xF0 7 | .map.funclib 0xE0 8 | .map.spm 0x00 9 | .map.lib 0x80 10 | 11 | 12 | //----------------------- 13 | .bss 0x2000 14 | uint8 PPU_CTRL1 15 | uint8 PPU_CTRL2 16 | uint8 PPU_STATUS 17 | uint8 SPR_ADD 18 | uint8 SPR_DATA 19 | uint8 PPU_SCROLL 20 | uint8 VRAM_ADD 21 | uint8 VRAM_DATA 22 | 23 | 24 | .bss 0x4014 25 | uint8 SPR_DMA 26 | //----------------------- 27 | 28 | .bss 0x600 29 | 30 | .code 0x8000 31 | proc _start: 32 | { 33 | asm " 34 | 35 | 36 | "; 37 | PPU_CTRL1 = 0x88 38 | PPU_CTRL2 = 0x1E 39 | 40 | jump main: 41 | } 42 | 43 | 44 | proc main: 45 | { 46 | 47 | uint16 testa,testb,res 48 | uint8 test8 49 | 50 | [res,idx,uint16] = 0x1234 51 | 52 | [res,idx,uint16] = testb + 0x1001 53 | 54 | [res,idx,uint16] = [res,idx,uint16] + 0x1003 55 | 56 | res = testb 57 | 58 | res = 0x1234 59 | 60 | res = [STR_HELLO:,idx,uint16] 61 | 62 | 63 | res = [STR_HELLO:,idx,uint16] + testb 64 | 65 | 66 | [res,idx,uint16] = [STR_HELLO:,idx,uint16] + 5 67 | 68 | res = 0x211 69 | 70 | res = testb +2 71 | res+=1 72 | 73 | 74 | res = testb >> 8 75 | res = testb << 8 76 | 77 | 78 | uint8 test 79 | if test & 3 80 | { 81 | 82 | } 83 | else 84 | { 85 | 86 | } 87 | 88 | do 89 | { 90 | }while 1 == 1 91 | 92 | } 93 | 94 | 95 | .org 0x800 96 | 97 | -------------------------------------------------------------------------------- /highlighting/vscode/themes/higueul-color-theme.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Higueul Color Theme", 3 | "type": "dark", 4 | "colors": { 5 | "editor.foreground": "#FFFFFF", 6 | "editor.background": "#1E1E1E", 7 | "editorCursor.foreground": "#FFFFFF", 8 | "editor.lineHighlightBackground": "#2A2A2A", 9 | "editorLineNumber.foreground": "#5A5A5A", 10 | "editor.selectionBackground": "#007ACC", 11 | "editor.selectionHighlightBackground": "#A6D3E0" 12 | }, 13 | "tokenColors": [ 14 | { 15 | "scope": "keyword.primary.higueul", 16 | "settings": { 17 | "foreground": "#151b6b", 18 | "fontStyle": "bold" 19 | } 20 | }, 21 | { 22 | "scope": "keyword.secondary.higueul", 23 | "settings": { 24 | "foreground": "#a33f2d" 25 | } 26 | }, 27 | { 28 | "scope": "keyword.third.higueul", 29 | "settings": { 30 | "foreground": "#8db82a" 31 | } 32 | }, 33 | { 34 | "scope": "keyword.quad.higueul", 35 | "settings": { 36 | "foreground": "#8b703d" 37 | } 38 | }, 39 | { 40 | "scope": "comment.block.higueul", 41 | "settings": { 42 | "foreground": "#234628" 43 | } 44 | }, 45 | { 46 | "scope": "comment.line.double-slash.higueul", 47 | "settings": { 48 | "foreground": "#234628" 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Cps1.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash compilation.sh 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=bash debug.sh 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=bash execute.sh 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | FT_02_LB= 17 | FT_02_CM= 18 | FT_02_WD= 19 | 20 | [styling=ASM] 21 | 22 | 23 | 24 | 25 | [keywords] 26 | # all items must be in one line 27 | # this is by default a very simple instruction set; not of Intel or so 28 | instructions=asl asl.b asl.w asl.l move move.b move.w move.l lea lea.b lea.w lea.l clr clr.b clr.w clr.l movem movem.b movem.w movem.l mulu mulu.b mulu.w mulu.l dbra add add.b add.w add.l addi addi.b addi.w addi.l and and.b and.w and.l andi andi.b andi.w andi.l neg neg.b neg.w neg.l nop mulu cmp bra btst jsr beq bne bpl bmi ble bge lsr lsr.b lsr.w lsr.l lsl lsl.b lsl.w lsl.l or or.b or.w or.l ori ori.b ori.w ori.l jmp btst btst.b btst.w btst.l add add.b add.w add.l cmp cmp.b cmp.w cmp.l sub sub.b sub.w sub.l rte rts tst tst.b tst.w tst.l subi subi.b subi.w subi.l cmpi cmpi.b cmpi.w cmpi.l 29 | registers=a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 sp pc usp ssp 30 | directives=org include incbin macro endm equ dc dc.b dc.w dc.l 31 | 32 | 33 | [settings] 34 | extension=sng 35 | 36 | lexer_filetype=ASM 37 | 38 | # multiline comments 39 | comment_open=/* 40 | comment_close=*/ 41 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.F3.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash compilation.sh 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=bash mame64.sh 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=bash execute.sh 10 | EX_00_WD= 11 | 12 | FT_01_LB= 13 | FT_01_CM= 14 | FT_01_WD= 15 | 16 | FT_02_LB= 17 | FT_02_CM= 18 | FT_02_WD= 19 | 20 | [styling=ASM] 21 | 22 | 23 | 24 | 25 | [keywords] 26 | # all items must be in one line 27 | # this is by default a very simple instruction set; not of Intel or so 28 | instructions=asl asl.b asl.w asl.l move move.b move.w move.l lea lea.b lea.w lea.l clr clr.b clr.w clr.l movem movem.b movem.w movem.l mulu mulu.b mulu.w mulu.l dbra add add.b add.w add.l addi addi.b addi.w addi.l and and.b and.w and.l andi andi.b andi.w andi.l neg neg.b neg.w neg.l nop mulu cmp bra btst jsr beq bne bpl bmi ble bge lsr lsr.b lsr.w lsr.l lsl lsl.b lsl.w lsl.l or or.b or.w or.l ori ori.b ori.w ori.l jmp btst btst.b btst.w btst.l add add.b add.w add.l cmp cmp.b cmp.w cmp.l sub sub.b sub.w sub.l rte rts tst tst.b tst.w tst.l subi subi.b subi.w subi.l cmpi cmpi.b cmpi.w cmpi.l st 29 | registers=a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 sp pc usp ssp 30 | directives=org include incbin macro endm equ dc dc.b dc.w dc.l 31 | 32 | 33 | [settings] 34 | extension=sng 35 | 36 | lexer_filetype=ASM 37 | 38 | # multiline comments 39 | comment_open=/* 40 | comment_close=*/ 41 | -------------------------------------------------------------------------------- /src/Eagle_struct.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //Variable pointeur 4 | typedef struct 5 | { 6 | int64_t value; // valeur immediate (si bimm == true) 7 | EAGLE_keywords type; //le type de variable 8 | bool bimm; //indique si c'est une valeur immediate 9 | char token1,token2; // indique les token devant et derriere si y'en a 10 | 11 | 12 | }EAGLE_VARIABLEP; 13 | 14 | 15 | //Variable 16 | typedef struct 17 | { 18 | int64_t immediate; // valeur immediate (si bimm == true) 19 | double dimmediate; // pareil mais en type double 20 | uint64_t address; //address si c'est une variable 21 | uint64_t nsize; // pas certain , mais probablement la taille de l'adresse ? 22 | EAGLE_keywords type,type2; // type de la variable (actuellement le type2 est inutilisé) 23 | char token1,token2; // indique les token devant et derriere si y'en a 24 | bool bimm; //indique si c'est une valeur immediate 25 | bool blabel; //indique si c'est un label 26 | bool bptr; //indique si c'est un pointeur 27 | bool ptr2_exist; //indique si un deuxieme pointeur existe 28 | 29 | // pour ptr1 et ptr2 , c'est pour [0x1000,idx] , ptr1 = 0x1000 et idx = ptr2 30 | 31 | EAGLE_VARIABLEP ptr1,ptr2; 32 | EAGLE_keywords ptr_type; // le type du ptr , si on écrit [var,idx] , il aura le type du var 33 | 34 | }EAGLE_VARIABLE; 35 | 36 | 37 | typedef struct 38 | { 39 | std::string item; 40 | std::string ptr[4]; 41 | EAGLE_keywords ktype; 42 | int ptype[4]; 43 | int type; 44 | int scope; 45 | int line,col,pn; 46 | char token1,token2; 47 | bool label; 48 | 49 | char ptoken1[4],ptoken2[4]; 50 | 51 | }EAGLE_WORDS; 52 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.Sng.conf: -------------------------------------------------------------------------------- 1 | [build-menu] 2 | FT_00_LB=_Compiler 3 | FT_00_CM=bash compile.sh 4 | FT_00_WD= 5 | EX_01_LB=Debug 6 | EX_01_CM=bash debug.sh 7 | EX_01_WD= 8 | EX_00_LB=_Exécuter 9 | EX_00_CM=gngeo --rompath=/%d ssideki 10 | EX_00_WD= 11 | 12 | FT_01_LB=Compiler CD 13 | FT_01_CM=/home/kannagi/Documents/SDK/NeoDev/m68k/vasmm68k_mot -Fbin -m68000 main.sng -o 052_p1.prg 14 | FT_01_WD= 15 | 16 | FT_02_LB=bin 17 | FT_02_CM=/home/kannagi/Documents/SDK/NeoDev/m68k/vasmm68k_mot -Fbin -m68000 main.sng -o 052-p1.bin 18 | FT_02_WD= 19 | 20 | [styling=ASM] 21 | 22 | 23 | 24 | 25 | [keywords] 26 | # all items must be in one line 27 | # this is by default a very simple instruction set; not of Intel or so 28 | instructions=asl asl.b asl.w asl.l move move.b move.w move.l lea lea.b lea.w lea.l clr clr.b clr.w clr.l movem movem.b movem.w movem.l mulu mulu.b mulu.w mulu.l dbra add add.b add.w add.l addi addi.b addi.w addi.l and and.b and.w and.l andi andi.b andi.w andi.l neg neg.b neg.w neg.l nop mulu cmp bra btst jsr beq bne bpl bmi ble bge lsr lsr.b lsr.w lsr.l lsl lsl.b lsl.w lsl.l or or.b or.w or.l ori ori.b ori.w ori.l jmp btst btst.b btst.w btst.l add add.b add.w add.l cmp cmp.b cmp.w cmp.l sub sub.b sub.w sub.l rte rts tst tst.b tst.w tst.l subi subi.b subi.w subi.l cmpi cmpi.b cmpi.w cmpi.l st 29 | registers=a0 a1 a2 a3 a4 a5 a6 a7 d0 d1 d2 d3 d4 d5 d6 d7 sp pc usp ssp 30 | directives=org include incbin macro endm equ dc dc.b dc.w dc.l 31 | 32 | 33 | [settings] 34 | extension=sng 35 | 36 | lexer_filetype=ASM 37 | 38 | # multiline comments 39 | comment_open=/* 40 | comment_close=*/ 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Higueul 2 | Higueul is a low-level programming language 3 | 4 | It has a syntax inspired by C and assembler. 5 | But don't think of it exactly as a C-like, It seems to be a bit C-like, but it has specificities, and can in some ways be close to a very advanced macro assembler. 6 | 7 | Wiki: https://github.com/Kannagi/Higueul/wiki 8 | 9 | Discord : https://discord.gg/cWa37SRgYU 10 | 11 | ### Who uses Higueul? 12 | 13 | - GameTank : https://github.com/clydeshaffer/GameTankHigueul 14 | - SNDK : https://github.com/Kannagi/SNDK 15 | 16 | ### Why did you create this language? 17 | 18 | If this is the question you are asking yourself, it is normal. 19 | 20 | There is an article that sums up what I think quite well: 21 | https://queue.acm.org/detail.cfm?id=3212479 22 | 23 | But the article is a bit long, so I will try to summarize the problem. 24 | C is not really a low level language, it assumes that you are on an "imaginary" machine and one in particular, a PDP-11 clone ! 25 | 26 | So if you have a CPU that is not a PDP-11 clone, what should you do ? 27 | Often code in assembler. 28 | 29 | Higueul is not a portable language, it may have specificities depending on the platform. 30 | 31 | Its purpose is not "old machine" oriented, nor even oriented for the SNES (since that is its primary use). 32 | But it is also made to be able to program on exotic processors like the Emotion Engine (PS2), the CELL (PS3), or GPU programming. 33 | 34 | ## Target 35 | 36 | - 6502 37 | - 65C02 38 | - Huc6280 39 | - 65816 40 | 41 | ## Next Target 42 | 43 | - z80 44 | - 8086/80186/80286 45 | - VU (PS2) 46 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. 7 | * `syntaxes/altairxasm.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. 8 | * `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. 9 | 10 | ## Get up and running straight away 11 | 12 | * Make sure the language configuration settings in `language-configuration.json` are accurate. 13 | * Press `F5` to open a new window with your extension loaded. 14 | * Create a new file with a file name suffix matching your language. 15 | * Verify that syntax highlighting works and that the language configuration settings are working. 16 | 17 | ## Make changes 18 | 19 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 20 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 21 | 22 | ## Add more language features 23 | 24 | * To add features such as IntelliSense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs 25 | 26 | ## Install your extension 27 | 28 | * To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. 29 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 30 | -------------------------------------------------------------------------------- /example/SNES/SNDK/macro.egl: -------------------------------------------------------------------------------- 1 | 2 | .macro SNDK_memcopy 3 | 4 | WMADD = .arg1; 5 | WMADDH = .arg2 6 | ; 7 | DMA_BANK_6 = .arg4; 8 | 9 | idy = .arg3; 10 | DMA_ADD_6 = idy; 11 | 12 | idy = .arg5; 13 | DMA_SIZE_6 = idy; 14 | 15 | MDMAEN = 0x40; 16 | 17 | .endmacro 18 | 19 | .macro SNDK_memset 20 | 21 | idy = $.arg1; 22 | WMADDH = idy; 23 | DMA_BANK_7 = 0x7E; 24 | 25 | SNDK_MEMSET = .arg2; 26 | idy = $SNDK_MEMSET; 27 | DMA_ADD_7 = idy; 28 | 29 | idy = .arg3; 30 | DMA_SIZE_7 = idy; 31 | 32 | MDMAEN = 0x80; 33 | 34 | .endmacro 35 | 36 | .macro SNDK_SendOAM 37 | 38 | idy = 0; 39 | OAMADD = idy; 40 | 41 | DMA_BANK_4 = 0x7E; 42 | 43 | idy = 0xD000; 44 | DMA_ADD_4 = idy; 45 | 46 | idy = 0x220; 47 | DMA_SIZE_4 = idy; 48 | 49 | MDMAEN = 0x10; 50 | .endmacro 51 | 52 | .macro SNDK_SendVRAM 53 | 54 | idy = .arg1; 55 | VMADD = idy; 56 | 57 | DMA_BANK_0 = #.arg2:; 58 | 59 | idy = $.arg2:; 60 | DMA_ADD_0 = idy; 61 | 62 | idy = .arg3; 63 | DMA_SIZE_0 = idy; 64 | 65 | MDMAEN = 1; 66 | .endmacro 67 | 68 | .macro SNDK_SendVRAM_ADR 69 | 70 | idy = .arg1; 71 | VMADD = idy; 72 | 73 | DMA_BANK_0 = .arg2; 74 | 75 | idy = .arg3; 76 | DMA_ADD_0 = idy; 77 | 78 | idy = .arg4; 79 | DMA_SIZE_0 = idy; 80 | 81 | MDMAEN = 1; 82 | .endmacro 83 | 84 | .macro SNDK_SendCGRAM 85 | 86 | CGADD = .arg1; 87 | 88 | DMA_BANK_5 = #.arg2:; 89 | 90 | idy = $.arg2:; 91 | DMA_ADD_5 = idy; 92 | 93 | idy = .arg3; 94 | DMA_SIZE_5 = idy; 95 | 96 | MDMAEN = 0x20; 97 | 98 | .endmacro 99 | 100 | .macro SNDK_SendCGRAM_ADR 101 | 102 | CGADD = .arg1; 103 | 104 | DMA_BANK_5 = .arg3; 105 | 106 | idy = .arg2; 107 | DMA_ADD_5 = idy; 108 | 109 | idy = .arg4; 110 | DMA_SIZE_5 = idy; 111 | 112 | MDMAEN = 0x20; 113 | 114 | .endmacro 115 | -------------------------------------------------------------------------------- /example/SNES/SNDK/VBlank.egl: -------------------------------------------------------------------------------- 1 | 2 | .org 0x7FB0 3 | .org 0x7FC0 4 | SNES_HEADER 5 | 6 | SNES_BANK 1 7 | 8 | 9 | func SNDK_VBlank:; 10 | { 11 | uint16 adrbg3; 12 | 13 | SNDK_SendOAM 14 | 15 | 16 | //------ 17 | 18 | //0x800 4 DMA SPRITE 19 | //0x20 palette 20 | //0x100 scrolling BG1&2 21 | //0x40 update 16x16 tile x2 22 | //0x40 update tilemap 23 | /* 24 | MODE16 25 | VMADD = 0x0000; 26 | DMA_ADD_0 = 0; 27 | DMA_SIZE_0 = (0x600+0x20+0x80+0x100+0x40); 28 | MODE8 29 | 30 | DMA_BANK_0 = 0x7F; 31 | 32 | MDMAEN = 1; 33 | */ 34 | 35 | //BG3 update line 36 | MODE16 37 | acc = adrbg3; 38 | acc = acc>>1; 39 | VMADD = acc + 0x5C00; 40 | 41 | DMA_ADD_0 = $SNDK_BG3.t1 + adrbg3; 42 | 43 | acc = adrbg3; 44 | acc += 0x80; 45 | if acc == 0x800 46 | { 47 | acc = 0; 48 | } 49 | adrbg3 = acc; 50 | 51 | DMA_SIZE_0 = 0x80; 52 | MODE8 53 | 54 | DMA_BANK_0 = #SNDK_BG3.t1; 55 | 56 | MDMAEN = 1; 57 | } 58 | 59 | func SNDK_WaitVBlank:; 60 | { 61 | acc = SNDK.clockf; 62 | acc += 1; 63 | if acc == 60 //60 frames 64 | { 65 | acc = SNDK.clocks; 66 | acc += 1; 67 | if acc == 60 //60 secondes 68 | { 69 | acc = SNDK.clockm; 70 | acc += 1; 71 | if acc == 60 //60 minutes 72 | { 73 | SNDK.clockh += 1; 74 | acc = 0; 75 | } 76 | SNDK.clockm = acc; 77 | acc = 0; 78 | } 79 | SNDK.clocks = acc; 80 | acc = 0; 81 | } 82 | SNDK.clockf = acc; 83 | 84 | acc = SLHV; 85 | acc = OPVCT; 86 | 87 | MODE16 88 | acc = acc & 0xFF; 89 | WRDIVL = acc << 6; 90 | MODE8 91 | WRDIVB = 143; 92 | if SNDK.mcpu < SNDK.cpu 93 | { 94 | SNDK.mcpu = SNDK.cpu; 95 | } 96 | 97 | if SNDK.pcpu < SNDK.cpu 98 | { 99 | SNDK.pcpu = SNDK.cpu; 100 | } 101 | 102 | SNDK.cpu = RDDIVL; 103 | 104 | VBlank.enable = 1; 105 | asm "wai"; 106 | VBlank.enable = 0; 107 | } 108 | -------------------------------------------------------------------------------- /example/test.egl: -------------------------------------------------------------------------------- 1 | //test comment 2 | 3 | /* 4 | 5 | comment two 6 | 7 | abcd 8 | */ 9 | 10 | .define TEST 50 11 | 12 | .macro ADD 13 | varg += TEST; 14 | varg += (10*2 + 5); 15 | .endmacro 16 | 17 | .macro ADD2 18 | varg += .arg1; 19 | varg += .arg2; 20 | .endmacro 21 | 22 | .rodata 23 | // 24 | 25 | 26 | 27 | .data.b 10,20,0x20,0x40; 28 | 29 | .incbin "text.txt" 30 | 31 | 32 | .data.s "hello world"; 33 | 34 | 35 | .data.f 1.12,1.5,0.0,1.0; 36 | .org 0x200 37 | 38 | str_hello: 39 | 40 | 41 | .bss 0x8000 42 | uint8 varg; 43 | 44 | .code 45 | .funcmap 0x200 46 | 47 | 48 | func main:uint8 arg1,uint8 arg2,uint8 arg3; 49 | { 50 | 51 | uint8 test; 52 | uint16 test2; 53 | spm uint8 var,var2$8,var3; 54 | 55 | if [test2,idx] == 5 56 | { 57 | return 0; 58 | } 59 | 60 | 61 | varg = [test2,idx] + [test,idx]; 62 | 63 | ADD 64 | 65 | 66 | 67 | ADD2 varg,20 68 | 69 | acc = var2 + main:; 70 | do 71 | { 72 | 73 | } 74 | while acc == 0 75 | 76 | if idx == 8 77 | { 78 | if idy == 8 79 | {idy = 1;} 80 | 81 | if idy == 8 82 | {idy = 1;} 83 | } 84 | else 85 | {idy = acc << 3;} 86 | 87 | if acc == arg2 88 | { 89 | 90 | } 91 | idy = idx << 3; 92 | 93 | idy = acc << 3; 94 | 95 | idy = arg2 << arg3; 96 | 97 | arg2 = 0; 98 | arg2 = (0x28+8); 99 | 100 | idx = 8; 101 | 102 | acc = arg2 + idy; 103 | 104 | acc = acc + arg3; 105 | 106 | idx += 1; 107 | 108 | 109 | acc += 2; 110 | 111 | arg3 = arg2 + arg1; 112 | 113 | acc = arg2 + idy; 114 | 115 | acc = idx + idy; 116 | arg1 = idx + idy; 117 | arg2 = idx + idx; 118 | 119 | call print:idx,5,test,idy; 120 | 121 | return arg1; 122 | 123 | arg2 = idx + idx; 124 | } 125 | 126 | 127 | 128 | func print:uint8 ap,uint8 ap1,uint8 ap2,uint8 ap3; 129 | { 130 | uint8 test; 131 | spm uint8 var,var2$8,var3; 132 | 133 | acc = test + ap; 134 | return; 135 | } 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /example/z80/demo.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Eagle_enum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define TYPE_LOOP 0 4 | #define TYPE_WHILE 1 5 | #define TYPE_IF 2 6 | 7 | enum class EAGLE_keywords : unsigned char 8 | { 9 | UNKNOW, 10 | 11 | //Variable 12 | INT8, 13 | INT16, 14 | INT32, 15 | INT64, 16 | 17 | UINT8, 18 | UINT16, 19 | UINT32, 20 | UINT64, 21 | 22 | FLOAT16, 23 | FLOAT32, 24 | FLOAT64, 25 | 26 | VFLOAT, 27 | VINT, 28 | 29 | VINT8x2, 30 | VINT16x2, 31 | VINT32x2, 32 | VINT64x2, 33 | 34 | VINT8x4, 35 | VINT16x4, 36 | VINT32x4, 37 | 38 | VINT8x8, 39 | VINT16x8, 40 | 41 | VFLOAT16x2, 42 | VFLOAT32x2, 43 | VFLOAT64x2, 44 | 45 | VFLOAT16x4, 46 | VFLOAT32x4, 47 | 48 | VFLOAT16x8, 49 | 50 | VOID, 51 | 52 | PTR, 53 | LABEL, 54 | IMM, 55 | 56 | REGISTER, 57 | SPM, 58 | LIB, 59 | STACK, 60 | 61 | EXTERN, 62 | 63 | //Control 64 | IF, 65 | ELSE, 66 | DO, 67 | WHILE, 68 | LOOP, 69 | JUMP, 70 | RETURN, 71 | CALL, 72 | 73 | //Function 74 | FUNC, 75 | FUNCSPM, 76 | FUNCLIB, 77 | FUNCREG, 78 | PROC, 79 | END, 80 | 81 | //extra 82 | ASM, 83 | ACC, 84 | REG1, 85 | REG2, 86 | REG3, 87 | REG4, 88 | REG5, 89 | REG6, 90 | REG7, 91 | REG8, 92 | REG9, 93 | REG10, 94 | REG11, 95 | REG12, 96 | REG13, 97 | REG14, 98 | REG15, 99 | REG16, 100 | REG17, 101 | REG18, 102 | REG19, 103 | REG20, 104 | REG21, 105 | REG22, 106 | REG23, 107 | REG24, 108 | REG25, 109 | REG26, 110 | REG27, 111 | REG28, 112 | REG29, 113 | REG30, 114 | 115 | REGSP, 116 | REGBC, 117 | REGDE, 118 | IDH, 119 | IDL, 120 | IDHL, 121 | IDX, 122 | IDY, 123 | 124 | //preproc 125 | DEFINE, 126 | MACRO, 127 | ENDMACRO, 128 | 129 | INCBIN, 130 | CODE, 131 | RODATA, 132 | BSS, 133 | FUNCMAP, 134 | FUNCMAPLIB, 135 | FUNCMAPSPM, 136 | SPMMAP, 137 | LIBMAP, 138 | ORG, 139 | 140 | 141 | //DATA ROW 142 | DATAB, 143 | DATAW, 144 | DATAL, 145 | DATAQ, 146 | DATAS, 147 | DATAH, 148 | DATAF, 149 | DATAD, 150 | }; 151 | 152 | -------------------------------------------------------------------------------- /highlighting/geany/filetype_extensions.conf: -------------------------------------------------------------------------------- 1 | # Filetype extension configuration file for Geany 2 | # Insert as many items as you want, seperate them with a ";". 3 | # See Geany's main documentation for details. 4 | [Extensions] 5 | Abaqus=*.inp; 6 | Abc=*.abc;*.abp; 7 | ActionScript=*.as; 8 | Ada=*.adb;*.ads; 9 | Asciidoc=*.asciidoc; 10 | ASM=*.asm; 11 | CAML=*.ml;*.mli; 12 | C=*.c;*.h; 13 | C++=*.cpp;*.cxx;*.c++;*.cc;*.h;*.hpp;*.hxx;*.h++;*.hh;*.C;*.H; 14 | C#=*.cs; 15 | CMake=CMakeLists.txt;*.cmake;*.ctest; 16 | COBOL=*.cob;*.cpy;*.cbl;*.cobol; 17 | Conf=*.conf;*.ini;config;*rc;*.cfg;*.desktop; 18 | CSS=*.css; 19 | Cython=*.pyx;*.pxd;*.pxi; 20 | D=*.d;*.di; 21 | Diff=*.diff;*.patch;*.rej; 22 | Docbook=*.docbook; 23 | Erlang=*.erl; 24 | F77=*.f;*.for;*.ftn;*.f77; 25 | Ferite=*.fe; 26 | Forth=*.fs;*.fth; 27 | Fortran=*.f90;*.f95;*.f03; 28 | FreeBasic=*.bas;*.bi; 29 | Genie=*.gs; 30 | GLSL=*.glsl;*.frag;*.vert; 31 | Go=*.go; 32 | Haskell=*.hs;*.lhs; 33 | Haxe=*.hx; 34 | HTML=*.htm;*.html;*.shtml;*.hta;*.htd;*.htt;*.cfm; 35 | Java=*.java;*.jsp; 36 | Javascript=*.js; 37 | LaTeX=*.tex;*.sty;*.idx;*.ltx;*.latex; 38 | Lisp=*.lisp; 39 | Lua=*.lua; 40 | Make=*.mak;*.mk;GNUmakefile;makefile;Makefile;makefile.*;Makefile.*; 41 | Markdown=*.mdml;*.markdown;*.md;*.mkd; 42 | Matlab/Octave=*.m; 43 | NSIS=*.nsi;*.nsh; 44 | Objective-C=*.m;*.mm;*.h; 45 | Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk; 46 | Perl=*.pl;*.perl;*.pm;*.agi;*.pod; 47 | PHP=*.php;*.php3;*.php4;*.php5;*.phtml; 48 | Po=*.po;*.pot; 49 | Python=*.py;*.pyw;SConstruct;SConscript; 50 | reStructuredText=*.rest;*.reST;*.rst; 51 | R=*.R;*.r; 52 | Ruby=*.rb;*.rhtml;*.ruby; 53 | Scala=*.scala;*.scl; 54 | Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.zsh;*.ash;*.bash;*.m4; 55 | SQL=*.sql; 56 | Tcl=*.tcl;*.tk;*.wish; 57 | Txt2tags=*.t2t; 58 | Vala=*.vala;*.vapi; 59 | Verilog=*.v; 60 | VHDL=*.vhd;*.vhdl; 61 | XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml; 62 | YAML=*.yaml;*.yml; 63 | None=; 64 | Sm=*.sm; 65 | Ast=*.ast; 66 | Sng=*.sng; 67 | Zng=*.zng; 68 | Cps1=*.cps1; 69 | F3=*.f3; 70 | Nes=*.ans; 71 | PCE=*.pcs; 72 | C64=*.a64; 73 | SPC=*.aspc; 74 | MD=*.mds; 75 | WIZ=*.wiz; 76 | Eagle=*.egl; 77 | 78 | # Note: restarting is required after editing groups 79 | [Groups] 80 | Programming=Cython;Genie;Go;Scala;Sm;Ast;Sng;Zng;Cps1;F3;Nes;PCE;C64;SPC;MD;WIZ;Eagle; 81 | Script= 82 | Markup= 83 | Misc= 84 | None= 85 | -------------------------------------------------------------------------------- /Higueul.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 67 | 68 | -------------------------------------------------------------------------------- /highlighting/Higueul-language-VSC/syntaxes/higueul.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Higueul language", 4 | "patterns": [ 5 | { 6 | "include": "#comment" 7 | }, 8 | { 9 | "include": "#strings" 10 | }, 11 | { 12 | "include": "#labels" 13 | }, 14 | { 15 | "include": "#directives" 16 | }, 17 | { 18 | "include": "#mnemonics" 19 | }, 20 | { 21 | "include": "#registers" 22 | }, 23 | { 24 | "include": "#numeric" 25 | } 26 | ], 27 | "repository": { 28 | "mnemonics": { 29 | "patterns": [ 30 | { 31 | "name": "keyword.control", 32 | "match": "\\b(bne|beq|bl|ble|bg|bge|bls|bles|bgs|bges|bra|loop|jump|call|jumpbr|callbr|ret|reti|syscall|int)\\b" 33 | }, 34 | { 35 | "name": "keyword.other.fixed", 36 | "match": "\\b(nop|moveix|ext|ins|movei|moven|umove|move)\\b" 37 | }, 38 | { 39 | "name": "keyword.other.sized", 40 | "match": "\\b(add|sub|xor|or|and|lsl|asr|lsr|se|slts|sltu|sand|hadd|hsub|hmul|hto|cmp|test|cmpfr|testfr|cmove|sext|rtl|rtr|adc|sbc|ld|st|ldv|stv|lds|sts|ldvs|stvs|div|divu|mul|mulu)((\\.[b|w|d|q])|)\\b" 41 | }, 42 | { 43 | "name": "keyword.operator", 44 | "match": "," 45 | } 46 | ] 47 | }, 48 | "registers": { 49 | "patterns": [ 50 | { 51 | "name": "variable.other", 52 | "match": "\\b(r|a|t|n|s|S|R|A|T|N|sp|SP)\\d*\\b" 53 | }, 54 | { 55 | "name": "variable.language", 56 | "match": "\\b(LR|lr|BR|br|LC|lc|FR|fr|PC|pc|IR|ir|CC|cc|IC|ic|PL|pl|PH|ph|PQ|pq|PR|pr)\\b" 57 | } 58 | ] 59 | }, 60 | "comment":{ 61 | "patterns": [{ 62 | "name": "comment.line", 63 | "match": ";.*" 64 | }] 65 | }, 66 | "strings": { 67 | "name": "string.quoted.double", 68 | "begin": "\"", 69 | "end": "\"", 70 | "patterns": [ 71 | { 72 | "name": "constant.character.escape", 73 | "match": "\\\\." 74 | } 75 | ] 76 | }, 77 | "numeric": { 78 | "patterns": [{ 79 | "name": "constant.numeric", 80 | "match": "(0x|0X|0b|0B|0o|0O|\\d)[\\dA-Fa-f]*(\\.\\d*(f|)|)" 81 | }] 82 | }, 83 | "labels": { 84 | "patterns": [{ 85 | "name": "entity.name.function", 86 | "match": "[\\w\\._-]*:" 87 | }] 88 | }, 89 | "directives": { 90 | "patterns": [{ 91 | "name": "constant.other", 92 | "match": "\\.\\w*" 93 | }] 94 | } 95 | }, 96 | "scopeName": "source.higueul" 97 | } -------------------------------------------------------------------------------- /example/gametank/main.egl: -------------------------------------------------------------------------------- 1 | .map.func 0x200 2 | .map.funcspm 0xF0 3 | .map.funclib 0xE0 4 | .map.spm 0x00 5 | .map.lib 0x80 6 | 7 | .bss 0x2000 8 | uint8 AUDIO_RESET 9 | uint8 AUDIO_NMI 10 | .bss 0x2005 11 | uint8 BANK_CTRL 12 | uint8 AUDIO_RATE 13 | uint8 VIDEO_CTRL 14 | uint8 GAMEPAD_1 15 | uint8 GAMEPAD_2 16 | 17 | .bss 0x4000 18 | uint8 BLIT_DSTX 19 | uint8 BLIT_DSTY 20 | uint8 BLIT_SRCX 21 | uint8 BLIT_SRCY 22 | uint8 BLIT_WIDTH 23 | uint8 BLIT_HEIGHT 24 | uint8 BLIT_START 25 | uint8 BLIT_COLOR 26 | 27 | //----------------------- 28 | 29 | .bss 0x600 30 | uint8 FRAME_FLAG 31 | uint8 rectX 32 | uint8 rectY 33 | uint8 velX 34 | uint8 velY 35 | .org 0x0000 36 | .code 0xC000 37 | proc _start: 38 | { 39 | asm " 40 | sei 41 | cld 42 | ldx #$FE 43 | txs 44 | 45 | "; 46 | AUDIO_RATE = 0x00; 47 | FRAME_FLAG = 0; 48 | rectX = 30; 49 | rectY = 10; 50 | velX = 1; 51 | velY = 1; 52 | jump main: 53 | } 54 | 55 | proc VBlank: 56 | { 57 | FRAME_FLAG = 0; 58 | asm "rti" 59 | } 60 | 61 | proc IRQ: 62 | { 63 | asm "rti" 64 | } 65 | 66 | 67 | 68 | proc main: 69 | { 70 | do 71 | { 72 | 73 | call BlitRectangle: rectX, rectY, 16, 16, (~28) 74 | 75 | VIDEO_CTRL = 77; 76 | 77 | BLIT_DSTX = 0; 78 | BLIT_DSTY = 0; 79 | BLIT_WIDTH = 127; 80 | BLIT_HEIGHT = 127; 81 | BLIT_COLOR = 252; 82 | BLIT_START = 1; 83 | .data.b 0xCB 84 | 85 | BLIT_DSTX = rectX; 86 | BLIT_DSTY = rectY; 87 | BLIT_WIDTH = 16; 88 | BLIT_HEIGHT = 16; 89 | BLIT_COLOR = 228; 90 | BLIT_START = 1; 91 | .data.b 0xCB 92 | 93 | rectX = rectX + velX; 94 | rectY = rectY + velY; 95 | if rectX == 111 96 | { 97 | velX = 255; 98 | } 99 | if rectX == 0 100 | { 101 | velX = 1; 102 | } 103 | if rectY == 111 104 | { 105 | velY = 255; 106 | } 107 | if rectY == 0 108 | { 109 | velY = 1; 110 | } 111 | 112 | call waitVBlank: 113 | }while 1 == 1 114 | 115 | } 116 | 117 | func waitVBlank: 118 | { 119 | FRAME_FLAG = 1; 120 | do 121 | { } 122 | while FRAME_FLAG == 1 123 | 124 | } 125 | 126 | funclib BlitRectangle:uint8 x, uint8 y, uint8 w, uint8 h, uint8 color; 127 | { 128 | VIDEO_CTRL = 73; 129 | BLIT_DSTX = x; 130 | BLIT_DSTY = y; 131 | BLIT_WIDTH = w; 132 | BLIT_HEIGHT = h; 133 | BLIT_COLOR = color; 134 | BLIT_START = 1; 135 | .data.b 0xCB 136 | } 137 | 138 | .org 0x1FFA 139 | .data.w VBlank 140 | .data.w _start 141 | .data.w IRQ 142 | 143 | .rodata 0x0000 144 | 145 | .org 0x2000 -------------------------------------------------------------------------------- /example/SNES/SNDK/crt0.egl: -------------------------------------------------------------------------------- 1 | 2 | SNES_BANK 0 3 | //error 4 | proc SNES_ERROR:; 5 | { 6 | spm uint16 tdebug1,tdebug2,tdebug3,tdebug4; 7 | spm uint16 reg1,reg2,reg3; 8 | 9 | asm "plx"; 10 | tdebug4 = idx; 11 | asm "phx"; 12 | MODE16 13 | reg1 = acc; 14 | reg2 = idx; 15 | reg3 = idy; 16 | 17 | MODE8 18 | 19 | call SNDK_PrintHexa16: reg1,2,8,SNDK_FONTPAL0; 20 | call SNDK_PrintHexa16: reg2,2,9,SNDK_FONTPAL0; 21 | call SNDK_PrintHexa16: reg3,2,10,SNDK_FONTPAL0; 22 | 23 | call SNDK_PrintHexa16: tdebug1,2,11,SNDK_FONTPAL0; 24 | call SNDK_PrintHexa16: tdebug2,2,12,SNDK_FONTPAL0; 25 | call SNDK_PrintHexa16: tdebug3,2,13,SNDK_FONTPAL0; 26 | call SNDK_PrintHexa16: tdebug4,2,14,SNDK_FONTPAL0; 27 | 28 | asm "rti"; 29 | } 30 | 31 | 32 | 33 | proc SNES_IRQHV:; 34 | { 35 | asm "rti"; 36 | } 37 | 38 | proc _start:; 39 | { 40 | asm " 41 | sei 42 | cld 43 | clc 44 | xce 45 | 46 | rep #$30 47 | ldx #$01FC 48 | txs 49 | phk 50 | pld 51 | lda #0 52 | tcd 53 | 54 | sep #$20 55 | 56 | ;fastrom 57 | jml _start_jump 58 | _start_jump: 59 | "; 60 | 61 | INIDISP = 0x80; //Forced Blank 62 | MEMSEL = 1; //mode 3.58 MHz 63 | 64 | call SNDK_Init:; 65 | 66 | jump main:; 67 | } 68 | 69 | func SNDK_Joypad:; 70 | { 71 | uint8 joya,joyb; 72 | 73 | acc = JOYSER0; 74 | joya = acc; 75 | if acc == 0 76 | { 77 | return; 78 | } 79 | 80 | acc = JOYSER1; 81 | joyb = acc; 82 | if acc == 0 83 | { 84 | return; 85 | } 86 | 87 | 88 | uint8 pad1l,pad2l,pad3l,pad4l; 89 | uint8 pad1h,pad2h,pad3h,pad4h; 90 | 91 | pad1l = STDCONTROL1L; 92 | pad2l = STDCONTROL2L; 93 | pad3l = STDCONTROL3L; 94 | pad4l = STDCONTROL4L; 95 | 96 | pad1h = STDCONTROL1H; 97 | pad2h = STDCONTROL2H; 98 | pad3h = STDCONTROL3H; 99 | pad4h = STDCONTROL4H; 100 | } 101 | 102 | proc VBlank:; 103 | { 104 | asm " 105 | jml FastVBlank 106 | FastVBlank: 107 | phd 108 | php 109 | 110 | phb 111 | pha 112 | phx 113 | phy 114 | 115 | sep #$20 116 | "; 117 | uint8 enable,wait; 118 | uint16 time; 119 | 120 | acc = RDNMI; 121 | 122 | if enable == 1 123 | { 124 | call SNDK_VBlank:; 125 | 126 | do 127 | { 128 | 129 | } 130 | while HVBJOY & 0x01 131 | call SNDK_Joypad:; 132 | 133 | idy = 0; 134 | if wait == 0 135 | { 136 | do 137 | { 138 | idy+=1; 139 | } 140 | while HVBJOY & 0x80 141 | } 142 | time = idy 143 | } 144 | 145 | 146 | asm " 147 | 148 | ply 149 | plx 150 | pla 151 | plb 152 | 153 | plp 154 | pld 155 | 156 | rti 157 | "; 158 | } 159 | -------------------------------------------------------------------------------- /highlighting/vscode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "higueul-highlighter", 3 | "displayName": "Higueul Highlighter", 4 | "description": "Extension pour surligner la syntaxe du langage Higueul", 5 | "version": "1.0.0", 6 | "publisher": "Kannagi", 7 | "engines": { 8 | "vscode": "^1.50.0" 9 | }, 10 | "categories": [ 11 | "Programming Languages" 12 | ], 13 | "contributes": { 14 | "languages": [ 15 | { 16 | "id": "higueul", 17 | "aliases": ["Higueul", "higueul"], 18 | "extensions": [".egl"], 19 | "configuration": "./language-configuration.json" 20 | } 21 | ], 22 | "grammars": [ 23 | { 24 | "language": "higueul", 25 | "scopeName": "source.higueul", 26 | "path": "./syntaxes/higueul.tmLanguage.json" 27 | } 28 | ], 29 | "tokenColorCustomizations": { 30 | "[Default Dark]": { 31 | "textMateRules": [ 32 | { 33 | "scope": "keyword.primary.higueul", 34 | "settings": { 35 | "foreground": "#151b6b", 36 | "fontStyle": "bold" 37 | } 38 | }, 39 | { 40 | "scope": "keyword.secondary.higueul", 41 | "settings": { 42 | "foreground": "#a33f2d" 43 | } 44 | }, 45 | { 46 | "scope": "keyword.third.higueul", 47 | "settings": { 48 | "foreground": "#8db82a" 49 | } 50 | }, 51 | { 52 | "scope": "keyword.quad.higueul", 53 | "settings": { 54 | "foreground": "#8b703d" 55 | } 56 | }, 57 | { 58 | "scope": "comment.line.double-slash.higueul", 59 | "settings": { 60 | "foreground": "#234628" 61 | } 62 | } 63 | ] 64 | }, 65 | "[Default Light]": { 66 | "textMateRules": [ 67 | { 68 | "scope": "keyword.primary.higueul", 69 | "settings": { 70 | "foreground": "#151b6b", 71 | "fontStyle": "bold" 72 | } 73 | }, 74 | { 75 | "scope": "keyword.secondary.higueul", 76 | "settings": { 77 | "foreground": "#a33f2d" 78 | } 79 | }, 80 | { 81 | "scope": "keyword.third.higueul", 82 | "settings": { 83 | "foreground": "#8db82a" 84 | } 85 | }, 86 | { 87 | "scope": "keyword.quad.higueul", 88 | "settings": { 89 | "foreground": "#8b703d" 90 | } 91 | }, 92 | { 93 | "scope": "comment.line.double-slash.higueul", 94 | "settings": { 95 | "foreground": "#234628" 96 | } 97 | } 98 | ] 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/Eagle_asm.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "Eagle.hpp" 13 | 14 | void Eagle::asm_bru(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 15 | { 16 | switch(this->target) 17 | { 18 | case TARGET_65816: 19 | asm_bru_65816(src1,src2,operator1,operator2,type,clabel); 20 | break; 21 | 22 | case TARGET_6502: 23 | case TARGET_65C02: 24 | case TARGET_HuC6520: 25 | asm_bru_6502(src1,src2,operator1,operator2,type,clabel); 26 | break; 27 | 28 | case TARGET_Z80: 29 | asm_bru_z80(src1,src2,operator1,operator2,type,clabel); 30 | break; 31 | 32 | case TARGET_AltairX: 33 | asm_bru_AltairX(src1,src2,operator1,operator2,type,clabel); 34 | break; 35 | } 36 | } 37 | 38 | void Eagle::asm_call_jump(const EAGLE_VARIABLE &src,int ninst,int type) 39 | { 40 | switch(this->target) 41 | { 42 | case TARGET_65816: 43 | asm_call_jump_65816(src,ninst,type); 44 | break; 45 | 46 | case TARGET_6502: 47 | case TARGET_65C02: 48 | case TARGET_HuC6520: 49 | asm_call_jump_6502(src,ninst,type); 50 | break; 51 | 52 | case TARGET_Z80: 53 | asm_call_jump_z80(src,ninst,type); 54 | break; 55 | 56 | case TARGET_AltairX: 57 | asm_call_jump_AltairX(src,ninst,type); 58 | break; 59 | } 60 | } 61 | 62 | void Eagle::asm_return(const EAGLE_VARIABLE &ret,bool retvoid) 63 | { 64 | switch(this->target) 65 | { 66 | case TARGET_65816: 67 | asm_return_65816(ret,retvoid); 68 | break; 69 | 70 | case TARGET_6502: 71 | case TARGET_65C02: 72 | case TARGET_HuC6520: 73 | asm_return_6502(ret,retvoid); 74 | break; 75 | 76 | case TARGET_Z80: 77 | asm_return_z80(ret,retvoid); 78 | break; 79 | 80 | case TARGET_AltairX: 81 | asm_return_AltairX(ret,retvoid); 82 | break; 83 | } 84 | } 85 | 86 | void Eagle::asm_alu(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 87 | { 88 | switch(this->target) 89 | { 90 | case TARGET_65816: 91 | asm_alu_65816(dst,src1,src2,operator1,operator2); 92 | break; 93 | 94 | case TARGET_6502: 95 | case TARGET_65C02: 96 | case TARGET_HuC6520: 97 | asm_alu_6502(dst,src1,src2,operator1,operator2); 98 | break; 99 | 100 | case TARGET_Z80: 101 | asm_alu_z80(dst,src1,src2,operator1,operator2); 102 | break; 103 | 104 | case TARGET_AltairX: 105 | asm_alu_AltairX(dst,src1,src2,operator1,operator2); 106 | break; 107 | } 108 | } 109 | 110 | void Eagle::asm_do_else() 111 | { 112 | switch(this->target) 113 | { 114 | case TARGET_65816: 115 | break; 116 | 117 | case TARGET_6502: 118 | case TARGET_65C02: 119 | case TARGET_HuC6520: 120 | break; 121 | 122 | case TARGET_Z80: 123 | 124 | break; 125 | 126 | case TARGET_AltairX: 127 | break; 128 | } 129 | } 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /example/gametank/out.asm: -------------------------------------------------------------------------------- 1 | .org $0000 2 | .code $C000 3 | ..begin _start 4 | _start: 5 | ;asm 6 | 7 | sei 8 | cld 9 | ldx #$FE 10 | txs 11 | 12 | 13 | ;AUDIO_RATE = 0x00 14 | stz 8198 15 | ;FRAME_FLAG = 0 16 | stz 1536 17 | ;rectX = 30 18 | lda #30 19 | sta 1537 20 | ;rectY = 10 21 | lda #10 22 | sta 1538 23 | ;velX = 1 24 | lda #1 25 | sta 1539 26 | ;velY = 1 27 | lda #1 28 | sta 1540 29 | ;jump main 30 | jmp main 31 | ..end 32 | ..begin VBlank 33 | VBlank: 34 | ;FRAME_FLAG = 0 35 | stz 1536 36 | ;asm 37 | rti 38 | ..end 39 | ..begin IRQ 40 | IRQ: 41 | ;asm 42 | rti 43 | ..end 44 | ..begin main 45 | main: 46 | .label_b0: 47 | ;call BlitRectangle 48 | lda 1537 49 | sta @BlitRectangle..arg0 50 | lda 1538 51 | sta @BlitRectangle..arg1 52 | lda #16 53 | sta @BlitRectangle..arg2 54 | lda #16 55 | sta @BlitRectangle..arg3 56 | lda #28 57 | sta @BlitRectangle..arg4 58 | jsr BlitRectangle 59 | ;VIDEO_CTRL = 77 60 | lda #77 61 | sta 8199 62 | ;BLIT_DSTX = 0 63 | stz 16384 64 | ;BLIT_DSTY = 0 65 | stz 16385 66 | ;BLIT_WIDTH = 127 67 | lda #127 68 | sta 16388 69 | ;BLIT_HEIGHT = 127 70 | lda #127 71 | sta 16389 72 | ;BLIT_COLOR = 252 73 | lda #252 74 | sta 16391 75 | ;BLIT_START = 1 76 | lda #1 77 | sta 16390 78 | .db $CB, 79 | ;BLIT_DSTX = rectX 80 | lda 1537 81 | sta 16384 82 | ;BLIT_DSTY = rectY 83 | lda 1538 84 | sta 16385 85 | ;BLIT_WIDTH = 16 86 | lda #16 87 | sta 16388 88 | ;BLIT_HEIGHT = 16 89 | lda #16 90 | sta 16389 91 | ;BLIT_COLOR = 228 92 | lda #228 93 | sta 16391 94 | ;BLIT_START = 1 95 | lda #1 96 | sta 16390 97 | .db $CB, 98 | ;rectX = rectX + velX 99 | lda 1537 100 | clc 101 | adc 1539 102 | sta 1537 103 | ;rectY = rectY + velY 104 | lda 1538 105 | clc 106 | adc 1540 107 | sta 1538 108 | ;if rectX == 111 109 | lda 1537 110 | cmp #111 111 | bne .label_1 112 | ;velX = 255 113 | lda #255 114 | sta 1539 115 | .label_1: 116 | ;if rectX == 0 117 | lda 1537 118 | cmp #0 119 | bne .label_2 120 | ;velX = 1 121 | lda #1 122 | sta 1539 123 | .label_2: 124 | ;if rectY == 111 125 | lda 1538 126 | cmp #111 127 | bne .label_3 128 | ;velY = 255 129 | lda #255 130 | sta 1540 131 | .label_3: 132 | ;if rectY == 0 133 | lda 1538 134 | cmp #0 135 | bne .label_4 136 | ;velY = 1 137 | lda #1 138 | sta 1540 139 | .label_4: 140 | ;call waitVBlank 141 | jsr waitVBlank 142 | .label_0: 143 | ;while 1 == 1 144 | 145 | jmp .label_b0 146 | ..end 147 | ..begin waitVBlank 148 | waitVBlank: 149 | ;FRAME_FLAG = 1 150 | lda #1 151 | sta 1536 152 | .label_b5: 153 | .label_5: 154 | ;while FRAME_FLAG == 1 155 | lda 1536 156 | cmp #1 157 | beq .label_b5 158 | rts 159 | ..end 160 | ..begin BlitRectangle 161 | BlitRectangle: 162 | ;VIDEO_CTRL = 73 163 | lda #73 164 | sta 8199 165 | ;BLIT_DSTX = x 166 | lda 224 167 | sta 16384 168 | ;BLIT_DSTY = y 169 | lda 225 170 | sta 16385 171 | ;BLIT_WIDTH = w 172 | lda 226 173 | sta 16388 174 | ;BLIT_HEIGHT = h 175 | lda 227 176 | sta 16389 177 | ;BLIT_COLOR = color 178 | lda 228 179 | sta 16391 180 | ;BLIT_START = 1 181 | lda #1 182 | sta 16390 183 | .db $CB, 184 | rts 185 | ..end 186 | .org $1FFA 187 | .dw @VBlank, 188 | .dw @_start, 189 | .dw @IRQ, 190 | .rodata $0000 191 | -------------------------------------------------------------------------------- /example/nes/main.egl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | .map.func 0x200 6 | .map.funcspm 0xF0 7 | .map.funclib 0xE0 8 | .map.spm 0x00 9 | .map.lib 0x80 10 | 11 | 12 | //--------header-------- 13 | .org 0 14 | .data.b 0x4E,0x45,0x53,0x1A 15 | .data.b 0x1 //PRG 16K* 16 | .data.b 0x4 //CHR 8K* 17 | .data.b 0x40 18 | .data.b 0x00,0x00 19 | 20 | .data.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00 21 | //----------------------- 22 | .bss 0x2000 23 | uint8 PPU_CTRL1 24 | uint8 PPU_CTRL2 25 | uint8 PPU_STATUS 26 | uint8 SPR_ADD 27 | uint8 SPR_DATA 28 | uint8 PPU_SCROLL 29 | uint8 VRAM_ADD 30 | uint8 VRAM_DATA 31 | 32 | 33 | .bss 0x4014 34 | uint8 SPR_DMA 35 | //----------------------- 36 | 37 | .bss 0x600 38 | 39 | .code 0x8000 40 | proc _start: 41 | { 42 | asm " 43 | sei 44 | cld 45 | ldx #$FE 46 | txs 47 | 48 | "; 49 | PPU_CTRL1 = 0x88 50 | PPU_CTRL2 = 0x1E 51 | 52 | jump main: 53 | } 54 | 55 | proc VBlank: 56 | { 57 | acc = PPU_STATUS 58 | 59 | VRAM_ADD = 0x3F 60 | VRAM_ADD = 0x00 61 | 62 | idx = 0 63 | idy = 4 64 | do 65 | { 66 | VRAM_DATA = [Pal1:,idx] 67 | idx += 1 68 | } 69 | loop idy == 0 70 | 71 | 72 | VRAM_ADD = 0x3F 73 | VRAM_ADD = 0x10 74 | 75 | idx = 0 76 | idy = 4 77 | do 78 | { 79 | VRAM_DATA = [Pal2:,idx] 80 | idx += 1 81 | } 82 | loop idy == 0 83 | 84 | VRAM_ADD = 0x20 85 | VRAM_ADD = 0x00 86 | 87 | 88 | idx = 0 89 | idy = 11 90 | do 91 | { 92 | VRAM_DATA = [STR_HELLO:,idx] 93 | idx += 1 94 | } 95 | loop idy == 0 96 | 97 | 98 | 99 | SPR_ADD = 16 100 | 101 | SPR_DATA = 120 102 | SPR_DATA = 0 103 | SPR_DATA = 0 104 | SPR_DATA = 120 105 | 106 | SPR_DATA = 120 107 | SPR_DATA = 1 108 | SPR_DATA = 0 109 | SPR_DATA = 128 110 | 111 | SPR_DATA = 128 112 | SPR_DATA = 2 113 | SPR_DATA = 0 114 | SPR_DATA = 120 115 | 116 | SPR_DATA = 128 117 | SPR_DATA = 3 118 | SPR_DATA = 0 119 | SPR_DATA = 128 120 | 121 | PPU_SCROLL = 0 122 | PPU_SCROLL = (-8) 123 | 124 | acc = 0 125 | asm "rti" 126 | } 127 | 128 | proc IRQ: 129 | { 130 | 131 | asm "rti" 132 | } 133 | 134 | 135 | 136 | proc main: 137 | { 138 | 139 | 140 | /* 141 | uint16 testa,testb,res 142 | uint8 test8 143 | 144 | [res,idx,uint16] = 0x1234 145 | 146 | [res,idx,uint16] = testb + 0x1001 147 | 148 | [res,idx,uint16] = [res,idx,uint16] + 0x1003 149 | 150 | res = testb 151 | 152 | res = 0x1234 153 | 154 | res = [STR_HELLO:,idx,uint16] 155 | 156 | 157 | res = [STR_HELLO:,idx,uint16] + testb 158 | 159 | 160 | [res,idx,uint16] = [STR_HELLO:,idx,uint16] + 5 161 | 162 | res = 0x211 163 | 164 | res = testb +2 165 | res+=1 166 | 167 | 168 | res = testb >> 8 169 | res = testb << 8 170 | 171 | 172 | uint8 test 173 | if test & 3 174 | { 175 | 176 | } 177 | else 178 | { 179 | 180 | } 181 | */ 182 | do 183 | { 184 | call waitVBlank: 185 | }while 1 == 1 186 | 187 | } 188 | 189 | func waitVBlank: 190 | { 191 | acc = 1; 192 | do 193 | { } 194 | while acc == 1 195 | 196 | } 197 | 198 | STR_HELLO: 199 | .data.s "HELLO_WORLD" 200 | 201 | 202 | Pal1: 203 | .incbin "font.pal" 204 | 205 | Pal2: 206 | .incbin "mario.pal" 207 | 208 | .org 0x400A 209 | .data.w VBlank 210 | .data.w _start 211 | .data.w IRQ 212 | 213 | .rodata 0x0000 214 | 215 | .incbin "font.spr" 216 | .org 0x5010 217 | .incbin "mario.spr" 218 | 219 | 220 | .org 0xC010 221 | 222 | -------------------------------------------------------------------------------- /example/SNES/main.egl: -------------------------------------------------------------------------------- 1 | 2 | proc main:; 3 | { 4 | SNDK_SendCGRAM 0x80,RANDI_PAL:,0x20 5 | 6 | SNDK_SendVRAM 0x6000,RANDI_SPR:,0x1000 7 | 8 | spm uint8 position.x,position.y,joypad; 9 | spm uint8 tmp; 10 | 11 | spm uint16 vx,vy; 12 | 13 | INIDISP = 0x0F; 14 | NMITIMEN = 0x81; 15 | 16 | position.x = 128; 17 | position.y = 128; 18 | 19 | call SNDK_PrintLine: $CPU_PER:,#CPU_PER:,23,0,SNDK_FONTPAL1; 20 | 21 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_0,100,100; 22 | 23 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_1,40,00; 24 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_2,40,40; 25 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_3,40,80; 26 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_4,40,120; 27 | 28 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_5,40,160; 29 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_6,40,200; 30 | 31 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_7,(-18),00; 32 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_8,(-18),40; 33 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_9,(-18),80; 34 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_10,(-18),120; 35 | 36 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_11,(-18),160; 37 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_12,(-18),200; 38 | 39 | 40 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_13,(160),100; 41 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_14,(200),120; 42 | call SNDK_SpriteEngineSetPosition:SPR_INDEX_15,(80),40; 43 | Game_Loop: 44 | 45 | 46 | idy = 0; 47 | idx = 0; 48 | if SNDK_Joypad.pad1h & SNDK_PAD_RIGHT 49 | { 50 | position.x += 1; 51 | idx = 0x6; 52 | } 53 | 54 | if SNDK_Joypad.pad1h & SNDK_PAD_LEFT 55 | { 56 | position.x -= 1; 57 | idx = (-0x6); 58 | } 59 | 60 | if SNDK_Joypad.pad1h & SNDK_PAD_DOWN 61 | { 62 | position.y += 1; 63 | idy = 0x6; 64 | } 65 | 66 | if SNDK_Joypad.pad1h & SNDK_PAD_UP 67 | { 68 | position.y -= 1; 69 | idy = (-0x6);; 70 | } 71 | vx = idx; 72 | vy = idy; 73 | 74 | call SNDK_SpriteEngineSetSpeed:SPR_INDEX_0,vx,vy; 75 | 76 | 77 | 78 | 79 | //call SNDK_PrintLine: $text_hello:,#text_hello:,12,5,SNDK_FONTPAL1; 80 | /* 81 | call SNDK_Print: $text_hello:,#text_hello:,12,12,SNDK_FONTPAL1; 82 | 83 | call SNDK_Print: $text_hello:,#text_hello:,12,12,SNDK_FONTPAL1; 84 | 85 | call SNDK_Print: $text_hello:,#text_hello:,12,12,SNDK_FONTPAL1; 86 | */ 87 | //call SNDK_Print: $text_hello:,#text_hello:,12,12,SNDK_FONTPAL1; 88 | 89 | 90 | 91 | //--------- 92 | call SNDK_Sprite:; 93 | 94 | //call SNDK_SpriteDrawMeta2x2: position.x,position.y,4,0x00; 95 | //call SNDK_SpriteDrawMeta2x2: 0,position.y,0,0; 96 | 97 | call SNDK_SpriteEngine:56,16; 98 | 99 | 100 | //------ 101 | 102 | 103 | if SNDK.clockf &1 104 | { 105 | call SNDK_PrintNumber8: SNDK.cpu,27,0,SNDK_FONTPAL2; 106 | //call SNDK_PrintNumber8: position.x,2,0,SNDK_FONTPAL0; 107 | //call SNDK_PrintNumber8: position.y,6,0,SNDK_FONTPAL0; 108 | } 109 | else 110 | { 111 | 112 | call SNDK_PrintHexa16: VBlank.time,26,1,SNDK_FONTPAL2; 113 | } 114 | 115 | 116 | 117 | call SNDK_WaitVBlank:; 118 | 119 | 120 | jump Game_Loop:; 121 | } 122 | 123 | 124 | func draw_text:; 125 | { 126 | 127 | 128 | } 129 | 130 | text_hello: 131 | .data.s "HELLO WORLD 132 | OK 133 | TEST 12345 134 | (0XFFFF) ! ?"; 135 | CPU_PER: 136 | .data.s "CPU:000!"; 137 | -------------------------------------------------------------------------------- /example/SNES/SNDK/Init.egl: -------------------------------------------------------------------------------- 1 | 2 | func SNDK_Init:; 3 | { 4 | VBlank.enable = 0; 5 | OBJSEL = SNDK_SPR_16_32; 6 | SNDK_SPR_META 16 7 | BGMODE = SNDK_MODE1; 8 | MOSAIC = 0x00; 9 | BG1SC = 0x54; 10 | BG2SC = 0x58; 11 | BG3SC = 0x5C; 12 | BG4SC = 0x50; 13 | BG12NBA = 0x00; //address BG1,2 $0000 14 | BG34NBA = 0x44; //address BG3,4 $4000 15 | 16 | BG3H0FS = 0; 17 | BG3H0FS = 0; 18 | 19 | BG3V0FS = 0; 20 | BG3V0FS = 0; 21 | 22 | BG4H0FS = 0; 23 | BG4H0FS = 0; 24 | 25 | BG4V0FS = 0; 26 | BG4V0FS = 0; 27 | 28 | VMAINC = 0x80; 29 | SETINI = 0x00; 30 | TM = 0x17; //bg 1,2,3 ,obj enable 31 | COLDATA = 0xE0; 32 | WRIO = 0xFF; 33 | NMITIMEN = 0x00; //Disable all 34 | SETINI = 0; 35 | 36 | TS = 0x00; 37 | CGSWSEL = 0x00; 38 | CGADSUB = 0x00; 39 | 40 | W12SEL = 0; 41 | W34SEL = 0; 42 | WOBJSEL = 0; 43 | M7SEL = 0; 44 | TMW = 0; 45 | TSW = 0; 46 | 47 | WH0 = 0; 48 | WH1 = 0; 49 | WH2 = 0; 50 | WH3 = 0; 51 | 52 | WBGLOG = 0; 53 | WOBJLOG = 0; 54 | 55 | M7A = 0; 56 | M7B = 0; 57 | M7C = 0; 58 | M7D = 0; 59 | M7X = 0; 60 | M7Y = 0; 61 | 62 | DMA_0 = 0x01; 63 | DMA_BADD_0 = 0x18; //VMDATA $1 64 | 65 | DMA_1 = 0x01; 66 | DMA_BADD_1 = 0x18; //VMDATA $2 67 | 68 | DMA_2 = 0x01; 69 | DMA_BADD_2 = 0x18; //VMDATA $4 70 | 71 | DMA_3 = 0x01; 72 | DMA_BADD_3 = 0x18; //VMDATA $8 73 | 74 | DMA_4 = 0x02; 75 | DMA_BADD_4 = 0x04; //OAMDATA $10 76 | 77 | DMA_5 = 0x02; 78 | DMA_BADD_5 = 0x22; //CGDATA $20 79 | 80 | DMA_6 = 0x00; 81 | DMA_BADD_6 = 0x80; //WMDATA memcopy $40 82 | 83 | DMA_7 = 0x08; 84 | DMA_BADD_7 = 0x80; //WMDATA memset $80 85 | 86 | 87 | 88 | //clear RAM 89 | MODE16 90 | idy = 0x3C0; 91 | idx = 0; 92 | do 93 | { 94 | acc = 0; 95 | [0x200,idx] = acc; 96 | [0x202,idx] = acc; 97 | [0x204,idx] = acc; 98 | [0x206,idx] = acc; 99 | idx += 8; 100 | } 101 | loop idy == 0 102 | 103 | idy = (0xE00); 104 | idx = 0; 105 | do 106 | { 107 | acc = 0; 108 | [0x7E2000,idx] = acc; 109 | [0x7E2002,idx] = acc; 110 | [0x7E2004,idx] = acc; 111 | [0x7E2006,idx] = acc; 112 | 113 | [0x7E2008,idx] = acc; 114 | [0x7E200A,idx] = acc; 115 | [0x7E200C,idx] = acc; 116 | [0x7E200E,idx] = acc; 117 | idx += 16; 118 | } 119 | loop idy == 0 120 | 121 | 122 | //VRAM CLEAR 123 | idx = 0; 124 | acc = 0; 125 | VMADD = idx; 126 | idy = (0x1000); 127 | do 128 | { 129 | VMDATA =acc; 130 | VMDATA =acc; 131 | VMDATA =acc; 132 | VMDATA =acc; 133 | 134 | VMDATA =acc; 135 | VMDATA =acc; 136 | VMDATA =acc; 137 | VMDATA =acc; 138 | } 139 | loop idy == 0 140 | 141 | 142 | //init sprite engine 143 | idy = 16; 144 | idx = 0; 145 | do 146 | { 147 | [SNDK_SPRITE.x,idx] = (-128); 148 | [SNDK_SPRITE.y,idx] = (-128); 149 | 150 | idx += 0x20; 151 | } 152 | loop idy == 0 153 | 154 | MODE8 155 | 156 | idy = 128; 157 | idx = 0; 158 | do 159 | { 160 | [SNDK_OAM0.y,idx] = 0xE0; 161 | idx += 4; 162 | } 163 | loop idy == 0 164 | 165 | SNDK_SendCGRAM 0x00,DATA_FONT_SNDK_P,0x20 166 | SNDK_SendVRAM 0x4000,DATA_FONT_SNDK_S,0x400 167 | 168 | 169 | SNDK_SendOAM 170 | } 171 | 172 | 173 | func SNDK_ModeAlpha:; 174 | { 175 | TS = 0x11; 176 | CGSWSEL = 0x02; 177 | CGADSUB = 0x42; 178 | } 179 | 180 | 181 | 182 | 183 | 184 | funclib tesss:uint8 ok; 185 | { 186 | spm uint8 ok1; 187 | lib uint8 ok2; 188 | ok = ok1 + ok2;; 189 | 190 | spm uint16 address; 191 | spm uint8 bank,tmp; 192 | idy = $text_hello:; 193 | address = idy; 194 | address = #text_hello:; 195 | 196 | idx = 0; 197 | spm uint16 idx1,idx2; 198 | idx1 = 0; 199 | idx2 = 0; 200 | do 201 | { 202 | tmp = @address; 203 | address +=1; 204 | 205 | } 206 | while tmp != 0 207 | 208 | 209 | idy = $text_hello:; 210 | address = idy; 211 | bank = #text_hello:; 212 | 213 | acc = address; 214 | acc = acc>>8; 215 | 216 | DMA_ADD_0 = $SNDK_BG3.t1 + address; 217 | 218 | DMA_ADD_0 = acc+ $SNDK_BG3.t1; 219 | idx = idx>>4; 220 | MODE16 221 | lib uint16 posxh; 222 | posxh = 0; 223 | ok1 = 5; 224 | ok = 8; 225 | } 226 | 227 | DATA_FONT_SNDK_S: 228 | .incbin "SNDK/fontm.spr" 229 | 230 | DATA_FONT_SNDK_P: 231 | .incbin "SNDK/fontm.pal" 232 | .incbin "SNDK/fontm2.pal" 233 | .incbin "SNDK/fontm3.pal" 234 | .data.w 0x7777,0; 235 | 236 | .org 0xFFB0 237 | .org 0xFFC0 238 | SNES_HEADER 239 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "Eagle.hpp" 14 | 15 | int rmakeLoad(const char *filename); 16 | 17 | static Eagle eagle; 18 | void test_constant(); 19 | int main() 20 | { 21 | //test_constant(); 22 | //return 0; 23 | eagle.target = TARGET_UNK; 24 | auto timer_start = std::chrono::high_resolution_clock::now(); 25 | 26 | rmakeLoad("higueul_make.txt"); 27 | 28 | auto timer_end = std::chrono::high_resolution_clock::now(); 29 | auto duration = std::chrono::duration_cast(timer_end - timer_start); 30 | 31 | std::cout << "version 0.4" << std::dec << std::endl; 32 | 33 | std::cout << "Time compilation: " << duration.count() << " millisecondes" << std::endl; 34 | 35 | return 0; 36 | } 37 | 38 | void rmake_option(char *buf) 39 | { 40 | std::string str = buf; 41 | 42 | std::istringstream iss(str); 43 | std::string word; 44 | 45 | // Parcourir chaque mot dans la chaîne 46 | while (iss >> word) 47 | { 48 | std::cout << word << "\n"; 49 | if(word == "-debug") 50 | { 51 | eagle.debug = true; 52 | } 53 | 54 | if(word == "-asm") 55 | { 56 | eagle.bout_asm = true; 57 | } 58 | 59 | if(word == "-cycle") 60 | { 61 | eagle.bcycle = true; 62 | } 63 | 64 | if(word == "-mesen") 65 | { 66 | eagle.bmesen = true; 67 | } 68 | 69 | if(word == "-snes-checksum") 70 | { 71 | eagle.snes_checksum = true; 72 | } 73 | 74 | if(word == "-65816") 75 | { 76 | eagle.target = TARGET_65816; 77 | } 78 | 79 | if(word == "-65C02") 80 | { 81 | eagle.target = TARGET_65C02; 82 | } 83 | 84 | 85 | if(word == "-6502") 86 | { 87 | eagle.target = TARGET_6502; 88 | } 89 | 90 | if(word == "-huc6280") 91 | { 92 | eagle.target = TARGET_HuC6520; 93 | } 94 | 95 | if(word == "-z80") 96 | { 97 | eagle.target = TARGET_Z80; 98 | } 99 | 100 | if(word == "-80186") 101 | { 102 | eagle.target = TARGET_80286; 103 | } 104 | 105 | if(word == "-AltairX") 106 | { 107 | eagle.target = TARGET_AltairX; 108 | } 109 | 110 | if(word == "-lc") 111 | { 112 | eagle.target = TARGET_C; 113 | } 114 | 115 | if(word == "-RV32") 116 | { 117 | eagle.target = TARGET_RV32; 118 | } 119 | } 120 | } 121 | 122 | 123 | void rmake_add_file(char *filename) 124 | { 125 | std::string str = filename; 126 | str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end()); 127 | 128 | eagle.load_file(str.c_str()); 129 | eagle.parser_word(); 130 | eagle.out_asm(); 131 | 132 | if(eagle.error != 0) 133 | exit(eagle.error); 134 | } 135 | 136 | void rmake_compile_run(char *target) 137 | { 138 | std::string str = target; 139 | eagle.filename = str; 140 | 141 | if (eagle.filename.length() >= 3) 142 | eagle.filename.replace(eagle.filename.length() - 3, 3, "mlb"); 143 | 144 | str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end()); 145 | 146 | if(eagle.target == TARGET_65816) 147 | { 148 | eagle.mesen_ram = "SnesWorkRam:"; 149 | eagle.mesen_rom = "SnesPrgRom"; 150 | eagle.bin_65816(); 151 | } 152 | 153 | if(eagle.target == TARGET_6502) 154 | { 155 | eagle.mesen_ram = "NesWorkRam:"; 156 | eagle.mesen_rom = "NesPrgRom"; 157 | eagle.bin_6502(); 158 | } 159 | 160 | if(eagle.target == TARGET_HuC6520) 161 | { 162 | eagle.mesen_ram = "PceWorkRam:"; 163 | eagle.mesen_rom = "PcePrgRom"; 164 | eagle.bin_6502(); 165 | } 166 | 167 | if(eagle.target == TARGET_65C02) 168 | { 169 | eagle.mesen_ram = "PceWorkRam:"; 170 | eagle.mesen_rom = "PcePrgRom"; 171 | eagle.bin_6502(); 172 | } 173 | 174 | if(eagle.target == TARGET_Z80) 175 | { 176 | eagle.bin_z80(); 177 | } 178 | 179 | if(eagle.target == TARGET_80286) 180 | { 181 | eagle.bin_80286(); 182 | } 183 | 184 | if(eagle.target == TARGET_AltairX) 185 | { 186 | eagle.bin_AltairX(); 187 | } 188 | 189 | if(eagle.target == TARGET_C) 190 | { 191 | 192 | } 193 | 194 | if(eagle.target == TARGET_UNK) 195 | { 196 | std::cout << "Target Unknow\n"; 197 | exit(-1); 198 | } 199 | 200 | if(eagle.bout_asm == true) 201 | eagle.write_file("out.asm",eagle.text_code); 202 | 203 | 204 | eagle.write_file_bin(target); 205 | } 206 | -------------------------------------------------------------------------------- /example/SNES/SNDK/Print.egl: -------------------------------------------------------------------------------- 1 | 2 | .macro PRINT_POSITION 3 | MODE16 4 | idx = py << 6; 5 | acc = px <<1; 6 | idx += acc; 7 | MODE8 8 | 9 | .endmacro 10 | 11 | funclib SNDK_PrintLine:uint16 adr,uint8 ibank,uint16 px,uint16 py,uint8 pal; 12 | { 13 | lib uint8 tpal; 14 | tpal = pal; 15 | PRINT_POSITION 16 | 17 | acc = @adr; 18 | do 19 | { 20 | [SNDK_BG3.t1,idx] = acc-32; 21 | [SNDK_BG3.t2,idx] = tpal; 22 | 23 | MODE16 24 | adr +=1; 25 | idx+=2; 26 | MODE8 27 | 28 | acc = @adr; 29 | } 30 | while acc!= 0 31 | } 32 | 33 | funclib SNDK_Print:uint16 adr,uint8 ibank,uint16 px,uint16 py,uint8 pal; 34 | { 35 | lib uint16 tpal,count; 36 | tpal = pal; 37 | idx = 2; 38 | count = idx; 39 | 40 | PRINT_POSITION 41 | acc = @adr; 42 | do 43 | { 44 | [SNDK_BG3.t1,idx] = acc-32; 45 | [SNDK_BG3.t2,idx] = tpal; 46 | 47 | MODE16 48 | adr +=1; 49 | idx+=2; 50 | count+=2; 51 | MODE8 52 | 53 | if @adr == 0x0A 54 | { 55 | MODE16 56 | idx +=0x40; 57 | idx -= count; 58 | count = 2; 59 | adr +=1; 60 | idx+=2; 61 | MODE8 62 | } 63 | } 64 | while @adr != 0 65 | } 66 | 67 | .macro PRINT_HEXA 68 | { 69 | acc = acc & 0xF; 70 | if acc >= 0xA 71 | { 72 | acc += 7; 73 | } 74 | acc += 0x10; 75 | } 76 | .endmacro 77 | 78 | .macro PRINT_DECIMAL100 79 | { 80 | if tnumber >= 100 81 | { 82 | tnumber -= 100; 83 | .arg1 += 1; 84 | } 85 | 86 | if tnumber >= 100 87 | { 88 | tnumber -= 100; 89 | .arg1 += 1; 90 | } 91 | 92 | } 93 | .endmacro 94 | 95 | .macro PRINT_DECIMAL 96 | { 97 | //5 98 | if tnumber >= .arg1 99 | { 100 | tnumber -= .arg1; 101 | .arg4 += 5; 102 | } 103 | 104 | //2 105 | if tnumber >= .arg2 106 | { 107 | tnumber -= .arg2; 108 | .arg4 += 2; 109 | } 110 | 111 | //2 112 | if tnumber >= .arg2 113 | { 114 | tnumber -= .arg2; 115 | .arg4 += 2; 116 | } 117 | 118 | //1 119 | if tnumber >= .arg3 120 | { 121 | tnumber -= .arg3; 122 | .arg4 += 1; 123 | } 124 | 125 | } 126 | .endmacro 127 | 128 | funclib SNDK_PrintNumber8:uint8 number,uint16 px,uint16 py,uint8 pal; 129 | { 130 | PRINT_POSITION 131 | 132 | lib uint8 tnumber1,tnumber2,tnumber; 133 | tnumber = number; 134 | tnumber1 = 0x10; 135 | tnumber2 = acc; 136 | 137 | PRINT_DECIMAL100 tnumber1 138 | [SNDK_BG3.t1,idx] = tnumber1; 139 | [SNDK_BG3.t2,idx] = pal; 140 | idx+=2; 141 | 142 | PRINT_DECIMAL 50,20,10,tnumber2 143 | [SNDK_BG3.t1,idx] = tnumber2; 144 | [SNDK_BG3.t2,idx] = pal; 145 | idx+=2; 146 | 147 | [SNDK_BG3.t1,idx] = tnumber + 0x10; 148 | [SNDK_BG3.t2,idx] = pal; 149 | } 150 | 151 | funclib SNDK_PrintNumber16:uint16 number,uint16 px,uint16 py,uint8 pal; 152 | { 153 | PRINT_POSITION 154 | 155 | MODE16 156 | 157 | lib uint16 tnumber1,tnumber2,tnumber3,tnumber4,tnumber; 158 | tnumber = number; 159 | tnumber1 = 0x10; 160 | tnumber2 = acc; 161 | tnumber3 = acc; 162 | tnumber4 = acc; 163 | 164 | PRINT_DECIMAL 50000,20000,10000,tnumber1 165 | PRINT_DECIMAL 5000,2000,1000,tnumber2 166 | PRINT_DECIMAL 500,200,100,tnumber3 167 | PRINT_DECIMAL 50,20,10,tnumber4 168 | 169 | MODE8 170 | [SNDK_BG3.t1,idx] = tnumber1; 171 | [SNDK_BG3.t2,idx] = pal; 172 | idx+=2; 173 | 174 | 175 | [SNDK_BG3.t1,idx] = tnumber2; 176 | [SNDK_BG3.t2,idx] = pal; 177 | idx+=2; 178 | 179 | [SNDK_BG3.t1,idx] = tnumber3; 180 | [SNDK_BG3.t2,idx] = pal; 181 | idx+=2; 182 | 183 | [SNDK_BG3.t1,idx] = tnumber4; 184 | [SNDK_BG3.t2,idx] = pal; 185 | idx+=2; 186 | 187 | [SNDK_BG3.t1,idx] = tnumber + 0x10; 188 | [SNDK_BG3.t2,idx] = pal; 189 | } 190 | 191 | funclib SNDK_PrintHexa8:uint8 number,uint16 px,uint16 py,uint8 pal; 192 | { 193 | PRINT_POSITION 194 | 195 | acc = number>>4; 196 | PRINT_HEXA 197 | [SNDK_BG3.t1,idx] = acc; 198 | [SNDK_BG3.t2,idx] = pal; 199 | idx+=2; 200 | 201 | acc = number; 202 | PRINT_HEXA 203 | [SNDK_BG3.t1,idx] = acc; 204 | [SNDK_BG3.t2,idx] = pal; 205 | } 206 | 207 | funclib SNDK_PrintHexa16:uint16 number,uint16 px,uint16 py,uint8 pal; 208 | { 209 | lib uint16 tnumber2,tnumber3; 210 | 211 | PRINT_POSITION 212 | MODE16 213 | acc = number; 214 | tnumber3 = acc>>4; 215 | tnumber2 = acc>>4; 216 | acc = acc>>4; 217 | MODE8 218 | 219 | 220 | PRINT_HEXA 221 | [SNDK_BG3.t1,idx] = acc; 222 | [SNDK_BG3.t2,idx] = pal; 223 | idx+=2; 224 | 225 | acc = tnumber2; 226 | PRINT_HEXA 227 | [SNDK_BG3.t1,idx] = acc; 228 | [SNDK_BG3.t2,idx] = pal; 229 | idx+=2; 230 | 231 | acc = tnumber3; 232 | PRINT_HEXA 233 | [SNDK_BG3.t1,idx] = acc; 234 | [SNDK_BG3.t2,idx] = pal; 235 | idx+=2; 236 | 237 | acc = number; 238 | PRINT_HEXA 239 | [SNDK_BG3.t1,idx] = acc; 240 | [SNDK_BG3.t2,idx] = pal; 241 | } 242 | 243 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # This makefile was generated by 'cbp2make' tool rev.147 # 3 | #------------------------------------------------------------------------------# 4 | 5 | 6 | WORKDIR = `pwd` 7 | 8 | CC = gcc 9 | CXX = g++ 10 | AR = ar 11 | LD = g++ 12 | WINDRES = windres 13 | 14 | INC = 15 | CFLAGS = -fomit-frame-pointer -Wextra -Wall -std=c++11 -fexceptions -Wno-unused-parameter 16 | RESINC = 17 | LIBDIR = 18 | LIB = 19 | LDFLAGS = -O1 -s 20 | 21 | INC_BIN = $(INC) -Isrc 22 | CFLAGS_BIN = $(CFLAGS) 23 | RESINC_BIN = $(RESINC) 24 | RCFLAGS_BIN = $(RCFLAGS) 25 | LIBDIR_BIN = $(LIBDIR) 26 | LIB_BIN = $(LIB) 27 | LDFLAGS_BIN = $(LDFLAGS) 28 | OBJDIR_BIN = obj 29 | DEP_BIN = 30 | OUT_BIN = bin/higueulc 31 | 32 | OBJ_BIN = $(OBJDIR_BIN)/src/Eagle_bin_80286.o $(OBJDIR_BIN)/src/rmake.o $(OBJDIR_BIN)/src/main.o $(OBJDIR_BIN)/src/constant_folding.o $(OBJDIR_BIN)/src/Eagle_parser.o $(OBJDIR_BIN)/src/Eagle_convert_asm.o $(OBJDIR_BIN)/src/Eagle_bin_z80.o $(OBJDIR_BIN)/src/Eagle_bin_AltairX.o $(OBJDIR_BIN)/src/Eagle.o $(OBJDIR_BIN)/src/Eagle_bin_65816.o $(OBJDIR_BIN)/src/Eagle_bin_6502.o $(OBJDIR_BIN)/src/Eagle_asm_z80.o $(OBJDIR_BIN)/src/Eagle_asm_AltairX.o $(OBJDIR_BIN)/src/Eagle_asm_80286.o $(OBJDIR_BIN)/src/Eagle_asm_65816.o $(OBJDIR_BIN)/src/Eagle_asm_6502.o $(OBJDIR_BIN)/src/Eagle_asm.o 33 | 34 | all: bin bin_windows 35 | 36 | clean: clean_bin clean_bin_windows 37 | 38 | before_bin: 39 | test -d bin || mkdir -p bin 40 | test -d $(OBJDIR_BIN)/src || mkdir -p $(OBJDIR_BIN)/src 41 | 42 | after_bin: 43 | 44 | bin: before_bin out_bin after_bin 45 | 46 | out_bin: before_bin $(OBJ_BIN) $(DEP_BIN) 47 | $(LD) $(LIBDIR_BIN) -o $(OUT_BIN) $(OBJ_BIN) $(LDFLAGS_BIN) $(LIB_BIN) 48 | 49 | $(OBJDIR_BIN)/src/Eagle_bin_80286.o: src/Eagle_bin_80286.cpp 50 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_bin_80286.cpp -o $(OBJDIR_BIN)/src/Eagle_bin_80286.o 51 | 52 | $(OBJDIR_BIN)/src/rmake.o: src/rmake.cpp 53 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/rmake.cpp -o $(OBJDIR_BIN)/src/rmake.o 54 | 55 | $(OBJDIR_BIN)/src/main.o: src/main.cpp 56 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/main.cpp -o $(OBJDIR_BIN)/src/main.o 57 | 58 | $(OBJDIR_BIN)/src/constant_folding.o: src/constant_folding.cpp 59 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/constant_folding.cpp -o $(OBJDIR_BIN)/src/constant_folding.o 60 | 61 | $(OBJDIR_BIN)/src/Eagle_parser.o: src/Eagle_parser.cpp 62 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_parser.cpp -o $(OBJDIR_BIN)/src/Eagle_parser.o 63 | 64 | $(OBJDIR_BIN)/src/Eagle_convert_asm.o: src/Eagle_convert_asm.cpp 65 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_convert_asm.cpp -o $(OBJDIR_BIN)/src/Eagle_convert_asm.o 66 | 67 | $(OBJDIR_BIN)/src/Eagle_bin_z80.o: src/Eagle_bin_z80.cpp 68 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_bin_z80.cpp -o $(OBJDIR_BIN)/src/Eagle_bin_z80.o 69 | 70 | $(OBJDIR_BIN)/src/Eagle_bin_AltairX.o: src/Eagle_bin_AltairX.cpp 71 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_bin_AltairX.cpp -o $(OBJDIR_BIN)/src/Eagle_bin_AltairX.o 72 | 73 | $(OBJDIR_BIN)/src/Eagle.o: src/Eagle.cpp 74 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle.cpp -o $(OBJDIR_BIN)/src/Eagle.o 75 | 76 | $(OBJDIR_BIN)/src/Eagle_bin_65816.o: src/Eagle_bin_65816.cpp 77 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_bin_65816.cpp -o $(OBJDIR_BIN)/src/Eagle_bin_65816.o 78 | 79 | $(OBJDIR_BIN)/src/Eagle_bin_6502.o: src/Eagle_bin_6502.cpp 80 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_bin_6502.cpp -o $(OBJDIR_BIN)/src/Eagle_bin_6502.o 81 | 82 | $(OBJDIR_BIN)/src/Eagle_asm_z80.o: src/Eagle_asm_z80.cpp 83 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm_z80.cpp -o $(OBJDIR_BIN)/src/Eagle_asm_z80.o 84 | 85 | $(OBJDIR_BIN)/src/Eagle_asm_AltairX.o: src/Eagle_asm_AltairX.cpp 86 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm_AltairX.cpp -o $(OBJDIR_BIN)/src/Eagle_asm_AltairX.o 87 | 88 | $(OBJDIR_BIN)/src/Eagle_asm_80286.o: src/Eagle_asm_80286.cpp 89 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm_80286.cpp -o $(OBJDIR_BIN)/src/Eagle_asm_80286.o 90 | 91 | $(OBJDIR_BIN)/src/Eagle_asm_65816.o: src/Eagle_asm_65816.cpp 92 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm_65816.cpp -o $(OBJDIR_BIN)/src/Eagle_asm_65816.o 93 | 94 | $(OBJDIR_BIN)/src/Eagle_asm_6502.o: src/Eagle_asm_6502.cpp 95 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm_6502.cpp -o $(OBJDIR_BIN)/src/Eagle_asm_6502.o 96 | 97 | $(OBJDIR_BIN)/src/Eagle_asm.o: src/Eagle_asm.cpp 98 | $(CXX) $(CFLAGS_BIN) $(INC_BIN) -c src/Eagle_asm.cpp -o $(OBJDIR_BIN)/src/Eagle_asm.o 99 | 100 | clean_bin: 101 | rm -f $(OBJ_BIN) $(OUT_BIN) 102 | rm -rf bin 103 | rm -rf $(OBJDIR_BIN)/src 104 | 105 | .PHONY: before_bin after_bin clean_bin 106 | 107 | -------------------------------------------------------------------------------- /example/SNES/SNDK/Sprite.egl: -------------------------------------------------------------------------------- 1 | 2 | func SNDK_Sprite:; 3 | { 4 | uint16 oam; 5 | 6 | //init OAM 7 | idy = 32; 8 | idx = 0; 9 | oam = idx; 10 | do 11 | { 12 | [SNDK_OAM0.y,idx] = 0xE0; 13 | [SNDK_OAM1.y,idx] = acc; 14 | [SNDK_OAM2.y,idx] = acc; 15 | [SNDK_OAM3.y,idx] = acc; 16 | 17 | idx += 16; 18 | } 19 | loop idy == 0 20 | 21 | idy = 0x8; 22 | idx = 0; 23 | 24 | MODE16 25 | acc = 0; 26 | do 27 | { 28 | 29 | [SNDK_OAMH,idx] = acc; 30 | [SNDK_OAMH,idx] = acc; 31 | idx += 2; 32 | [SNDK_OAMH,idx] = acc; 33 | [SNDK_OAMH,idx] = acc; 34 | idx += 2; 35 | } 36 | loop idy == 0 37 | MODE8 38 | 39 | //SNDK_memset SNDK_OAM0.y,0x00,0x220 40 | 41 | 42 | 43 | } 44 | 45 | 46 | funclib SNDK_SpriteEngine:uint16 oam,uint16 n; 47 | { 48 | //init 49 | lib uint16 posx,posy; 50 | lib uint8 tile,attribute; 51 | lib uint16 posxh,indexh; 52 | MODE16 53 | if n > 16 54 | { 55 | n = 16; 56 | } 57 | idy = n; 58 | idx = 0; 59 | SNDK_Sprite.oam = oam<<2; 60 | 61 | do 62 | { 63 | [SNDK_SPRITE.x,idx] += [SNDK_SPRITE.vx,idx]; 64 | posx = acc>>2; 65 | 66 | [SNDK_SPRITE.y,idx] += [SNDK_SPRITE.vy,idx]; 67 | posy = acc>>2; 68 | 69 | tile = [SNDK_SPRITE.t,idx] ; 70 | 71 | 72 | 73 | asm "phx"; 74 | 75 | call SNDK_SpriteEngineDraw:; 76 | 77 | SNDK_Sprite.oam += 0x10; 78 | asm "plx"; 79 | 80 | 81 | if posxh == 0x3F00 82 | { 83 | 84 | }else 85 | { 86 | 87 | } 88 | 89 | idx+= 0x20; 90 | } 91 | loop idy == 0 92 | 93 | MODE8 94 | } 95 | 96 | 97 | funclib SNDK_SpriteEngineDraw:; 98 | { 99 | 100 | lib uint16 posx,posy; 101 | lib uint8 tile,attribute; 102 | lib uint16 posxh,indexh; 103 | 104 | 105 | MODE16 106 | acc = posy + 0xC020; 107 | if acc & 0x3F00 108 | { 109 | return; 110 | } 111 | 112 | posxh = 0; 113 | idx = SNDK_Sprite.oam; 114 | indexh = idx>>4; 115 | 116 | acc = posx + 0xC010; 117 | if acc ?= 0 118 | { 119 | posxh = 0x11; 120 | }else 121 | { 122 | acc += 0x10; 123 | if acc ?= 0 124 | { 125 | posxh = 0x55; 126 | }else 127 | { 128 | acc -= 0x20; 129 | if acc & 0x3F00 130 | { 131 | return; 132 | } 133 | 134 | } 135 | 136 | } 137 | 138 | MODE8 139 | /* 140 | [SNDK_OAM0.x,idx] = posx; 141 | [SNDK_OAM0.y,idx] = posy; 142 | [SNDK_OAM0.t,idx] = tile; 143 | [SNDK_OAM0.a,idx] = attribute; 144 | */ 145 | 146 | 147 | acc = posy; 148 | [SNDK_OAM0.y,idx] = acc; 149 | [SNDK_OAM1.y,idx] = acc; 150 | [SNDK_OAM2.y,idx] = acc+SNDK_SPR_SIZE; 151 | [SNDK_OAM3.y,idx] = acc; 152 | 153 | acc = posx; 154 | [SNDK_OAM0.x,idx] = acc; 155 | [SNDK_OAM2.x,idx] = acc; 156 | 157 | 158 | acc += SNDK_SPR_SIZE; 159 | if acc ?! 0 160 | { 161 | [SNDK_OAM1.x,idx] = acc; 162 | [SNDK_OAM3.x,idx] = acc; 163 | }else 164 | { 165 | if posxh == 0x11 166 | { 167 | [SNDK_OAM1.x,idx] = posx + SNDK_SPR_SIZE; 168 | [SNDK_OAM3.x,idx] = acc; 169 | }else 170 | { 171 | [SNDK_OAM1.y,idx] = 0xE0; 172 | [SNDK_OAM3.y,idx] = 0xE0; 173 | } 174 | } 175 | 176 | 177 | acc = tile; 178 | [SNDK_OAM0.t,idx] = acc; 179 | [SNDK_OAM1.t,idx] = acc+SNDK_SPR_SIZET; 180 | [SNDK_OAM2.t,idx] = acc+0x1E; 181 | [SNDK_OAM3.t,idx] = acc+SNDK_SPR_SIZET; 182 | 183 | acc = attribute; 184 | [SNDK_OAM0.a,idx] = acc; 185 | [SNDK_OAM1.a,idx] = acc; 186 | [SNDK_OAM2.a,idx] = acc; 187 | [SNDK_OAM3.a,idx] = acc; 188 | 189 | idx = indexh; 190 | [SNDK_OAMH,idx] = posxh; 191 | 192 | MODE16 193 | 194 | } 195 | 196 | funclib SNDK_SpriteEngineSetSpeed:uint16 index,uint16 mx,uint16 my; 197 | { 198 | MODE16 199 | idx =index; 200 | [SNDK_SPRITE.vx,idx] = mx; 201 | [SNDK_SPRITE.vy,idx] = my; 202 | 203 | MODE8 204 | 205 | } 206 | 207 | funclib SNDK_SpriteEngineSetPosition:uint16 index,uint16 px,uint16 py; 208 | { 209 | MODE16 210 | idx =index; 211 | [SNDK_SPRITE.x,idx] = px<<2; 212 | [SNDK_SPRITE.y,idx] = py<<2; 213 | MODE8 214 | } 215 | 216 | funclib SNDK_SpriteDraw:uint8 position.x,uint8 position.y,uint8 tile,uint8 attribute; 217 | { 218 | idx = SNDK_Sprite.oam; 219 | [SNDK_OAM0.x,idx] = position.x; 220 | [SNDK_OAM0.y,idx] = position.y; 221 | [SNDK_OAM0.t,idx] = tile; 222 | [SNDK_OAM0.a,idx] = attribute; 223 | 224 | SNDK_Sprite.oam = idx + 4; 225 | } 226 | 227 | funclib CONTROL:uint16 a1,uint16 a2,uint16 a3,uint16 a4; 228 | { 229 | lib uint16 b1,b2,b3,b4,b5,b6,b7; 230 | spm uint16 c1,c2,c3,c4,c5,c6,c7; 231 | MODE16 232 | acc = 0xFFFF; 233 | 234 | a1 = acc; 235 | a2 = acc; 236 | a3 = acc; 237 | a4 = acc; 238 | 239 | b1 = acc; 240 | b2 = acc; 241 | b3 = acc; 242 | b4 = acc; 243 | b5 = acc; 244 | b6 = acc; 245 | b7 = acc; 246 | 247 | c1 = acc; 248 | c2 = acc; 249 | c3 = acc; 250 | c4 = acc; 251 | c5 = acc; 252 | c6 = acc; 253 | c7 = acc; 254 | 255 | 256 | MODE8 257 | } 258 | 259 | 260 | funclib SNDK_SpriteDrawMeta2x2:uint8 position.x,uint8 position.y,uint8 tile,uint8 attribute; 261 | { 262 | idx = SNDK_Sprite.oam; 263 | 264 | 265 | acc = position.x; 266 | [SNDK_OAM0.x,idx] = acc; 267 | [SNDK_OAM2.x,idx] = acc; 268 | [SNDK_OAM1.x,idx] = acc+SNDK_SPR_SIZE; 269 | [SNDK_OAM3.x,idx] = acc; 270 | 271 | acc = position.y; 272 | [SNDK_OAM0.y,idx] = acc; 273 | [SNDK_OAM1.y,idx] = acc; 274 | [SNDK_OAM2.y,idx] = acc+SNDK_SPR_SIZE; 275 | [SNDK_OAM3.y,idx] = acc; 276 | 277 | acc = tile; 278 | [SNDK_OAM0.t,idx] = acc; 279 | [SNDK_OAM1.t,idx] = acc+SNDK_SPR_SIZET; 280 | [SNDK_OAM2.t,idx] = acc+0x1E; 281 | [SNDK_OAM3.t,idx] = acc+SNDK_SPR_SIZET; 282 | 283 | acc = attribute; 284 | [SNDK_OAM0.a,idx] = acc; 285 | [SNDK_OAM1.a,idx] = acc; 286 | [SNDK_OAM2.a,idx] = acc; 287 | [SNDK_OAM3.a,idx] = acc; 288 | 289 | MODE16 290 | SNDK_Sprite.oam = idx + 16; 291 | MODE8 292 | } 293 | -------------------------------------------------------------------------------- /src/rmake.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define MAX_ENTRIES 4000 7 | 8 | void rmake_add_file(char *filename); 9 | void rmake_option(char *filename); 10 | 11 | void rmake_compile_run(char *target); 12 | 13 | void listFilesRecursive(const char *path, char *entries[], int *entryCount) 14 | { 15 | DIR *dir; 16 | struct dirent *entry; 17 | struct stat info; 18 | 19 | if ((dir = opendir(path)) == NULL) 20 | { 21 | perror("opendir"); 22 | exit(EXIT_FAILURE); 23 | } 24 | 25 | while ((entry = readdir(dir)) != NULL) 26 | { 27 | // Ignore "." and ".." 28 | if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) 29 | continue; 30 | 31 | char fullPath[1024]; 32 | snprintf(fullPath, sizeof(fullPath), "%s/%s", path, entry->d_name); 33 | 34 | // Store the file path in entries array 35 | entries[*entryCount] = strdup(fullPath); 36 | (*entryCount)++; 37 | 38 | 39 | if (stat(fullPath, &info) != 0) { 40 | perror("stat"); 41 | continue; 42 | } 43 | 44 | if (S_ISDIR(info.st_mode)) { 45 | // It's a directory 46 | listFilesRecursive(fullPath, entries, entryCount); 47 | } else { 48 | int l = strlen(fullPath); 49 | if( (fullPath[l-4] == '.') && (fullPath[l-3] == 'e') && (fullPath[l-2] == 'g') && (fullPath[l-1] == 'l') ) 50 | { 51 | //printf("konw format %s\n",fullPath); 52 | rmake_add_file(fullPath); 53 | 54 | }//else 55 | //printf("unkonw format %s\n",fullPath); 56 | } 57 | 58 | } 59 | 60 | closedir(dir); 61 | } 62 | 63 | void listFiles(const char *path) 64 | { 65 | char *entries[MAX_ENTRIES]; 66 | int entryCount = 0; 67 | 68 | listFilesRecursive(path, entries, &entryCount); 69 | 70 | for (int i = 0; i < entryCount; i++) 71 | free(entries[i]); 72 | } 73 | 74 | void* loadFile(const char* filename,int *sz) 75 | { 76 | int fileSize; 77 | FILE* file = fopen(filename, "r"); 78 | if (file == NULL) 79 | { 80 | fprintf(stderr, "Impossible to open the file : %s\n", filename); 81 | return NULL; 82 | } 83 | 84 | fseek(file, 0, SEEK_END); 85 | fileSize = ftell(file); 86 | fseek(file, 0, SEEK_SET); 87 | 88 | if (fileSize <= 0) 89 | { 90 | fprintf(stderr, "Empty file: %s\n", filename); 91 | fclose(file); 92 | return NULL; 93 | } 94 | 95 | 96 | char* buffer = (char*)malloc(fileSize+2); 97 | if (buffer == NULL) 98 | { 99 | fprintf(stderr, "Memory allocation error :%s /%d\n",filename,fileSize); 100 | fclose(file); 101 | return NULL; 102 | } 103 | 104 | int bytesRead = fread(buffer, 1, fileSize, file); 105 | if(bytesRead != fileSize) 106 | { 107 | fprintf(stderr, "Error reading file : %s\n", filename); 108 | fclose(file); 109 | free(buffer); 110 | return NULL; 111 | } 112 | 113 | fclose(file); 114 | 115 | *sz = fileSize; 116 | 117 | buffer[fileSize] = 0; 118 | 119 | return buffer; 120 | } 121 | 122 | 123 | int rmake_keyword(char *keywords) 124 | { 125 | if(strcmp(keywords,"options") == 0) 126 | return 0; 127 | 128 | if(strcmp(keywords,"cmd_execute") == 0) 129 | return 1; 130 | 131 | if(strcmp(keywords,"compiler_run") == 0) 132 | return 2; 133 | 134 | if(strcmp(keywords,"add_folder") == 0) 135 | return 3; 136 | 137 | if(strcmp(keywords,"add_file") == 0) 138 | return 4; 139 | 140 | return -1; 141 | } 142 | 143 | 144 | void rmakeInit(char *buffer,int n) 145 | { 146 | int l = 0; 147 | char keywords[32]; 148 | char buf[2048]; 149 | char filename[256]; 150 | int lec = 0; 151 | int kcmd = -1; 152 | 153 | for(int i = 0;i < n ;i++) 154 | { 155 | if(buffer[i] == '#') 156 | { 157 | while((buffer[i] != '\n') && (i < n)) i++; 158 | } 159 | 160 | if(buffer[i] >= ' ') 161 | { 162 | if(lec == 0) 163 | { 164 | l = 0; 165 | while((buffer[i] != ':') && (i < n)) 166 | { 167 | keywords[l] = buffer[i]; 168 | i++; 169 | l++; 170 | } 171 | 172 | if(l > 0) 173 | { 174 | keywords[l] = 0; 175 | l = 0; 176 | //printf("key:%s\n",keywords); 177 | 178 | kcmd = rmake_keyword(keywords); 179 | 180 | lec = 1; 181 | } 182 | 183 | if(buffer[i+1] == '\n') 184 | lec = 0; 185 | } 186 | else 187 | { 188 | if(kcmd != -1) 189 | { 190 | l = 0; 191 | while((buffer[i] != '\n') && (i < n)) 192 | { 193 | buf[l] = buffer[i]; 194 | i++; 195 | l++; 196 | } 197 | buf[l] = 0; 198 | //printf("cmd:%s \n",buf); 199 | 200 | if(l > 0) 201 | { 202 | if(kcmd == 1) //cmd_execute 203 | { 204 | system(buf); 205 | }else 206 | if(kcmd == 2) //compiler_run 207 | { 208 | rmake_compile_run(buf); 209 | }else 210 | { 211 | int bn = strlen(buf); 212 | int j = 0; 213 | while(j < bn) 214 | { 215 | 216 | int k = 0; 217 | while((buf[j] != ';') && (j < bn)) 218 | { 219 | filename[k] = buf[j]; 220 | k++; 221 | j++; 222 | } 223 | j++; 224 | filename[k] = 0; 225 | 226 | if(kcmd == 0) // option 227 | { 228 | rmake_option(filename); 229 | } 230 | 231 | if(kcmd == 3) //add_folder 232 | { 233 | listFiles(filename); 234 | } 235 | 236 | if(kcmd == 4) //add_file 237 | { 238 | rmake_add_file(filename); 239 | } 240 | 241 | } 242 | 243 | } 244 | 245 | 246 | l = 0; 247 | } 248 | }else 249 | { 250 | while((buffer[i] != '\n') && (i < n)) i++; 251 | } 252 | 253 | lec = 0; 254 | } 255 | 256 | 257 | } 258 | } 259 | } 260 | 261 | 262 | 263 | int rmakeLoad(const char *filename) 264 | { 265 | char *buffer = NULL; 266 | int fsize; 267 | 268 | buffer = (char*)loadFile(filename,&fsize); 269 | if (buffer == NULL) 270 | { 271 | printf("Error: Unable to open higueul_make.txt file\n"); 272 | return 0; 273 | } 274 | 275 | 276 | rmakeInit(buffer,fsize); 277 | 278 | //rmakeCreate(&rmake); 279 | 280 | return 0; 281 | } 282 | 283 | 284 | -------------------------------------------------------------------------------- /highlighting/geany/filedefs/filetypes.common: -------------------------------------------------------------------------------- 1 | # For complete documentation of this file, please see Geany's main documentation 2 | 3 | [styling] 4 | # use foreground;background;bold;italic or named_style,bold,italic 5 | 6 | # used for filetype All/None 7 | default=default 8 | 9 | # 3rd selection argument is true to override default foreground 10 | # 4th selection argument is true to override default background 11 | selection=selection 12 | # style for a matching brace 13 | brace_good=brace_good 14 | # style for a non-matching brace (a brace without a counterpart) 15 | brace_bad=brace_bad 16 | 17 | # the following settings define the colours of the margins on the left side 18 | margin_linenumber=margin_line_number 19 | margin_folding=margin_folding 20 | fold_symbol_highlight=fold_symbol_highlight 21 | 22 | # background colour of the current line, only the second and third argument is interpreted 23 | # use the third argument to enable or disable the highlighting of the current line (has to be true/false) 24 | current_line=current_line 25 | 26 | # translucency for the current line(first argument) and the selection (second argument) 27 | # values between 0 and 256 are accepted. Note for Windows 95, 98 and ME users: 28 | # keep this value at 256 to disable translucency otherwise Geany might crash 29 | translucency=256;256 30 | 31 | # style for a highlighted line (e.g when using Goto line or goto tag) 32 | marker_line=marker_line 33 | 34 | # style for a marked search results (when using "Mark" in Search dialogs) 35 | # the second argument sets the background colour for the drawn rectangle 36 | # only the second argument is interpreted 37 | marker_search=marker_search 38 | 39 | # style for a marked line (e.g when using the "Toggle Marker" keybinding (Ctrl-M)) 40 | marker_mark=marker_mark 41 | 42 | # translucency for the line marker(first argument) and the search marker (second argument) 43 | marker_translucency=256;256 44 | 45 | # colour of the caret(the blinking cursor), only first and third argument is interpreted 46 | # set the third argument to true to change the caret into a block caret 47 | caret=caret 48 | 49 | # width of the caret(the blinking cursor) 50 | # width in pixels, use 0 to make it invisible, maximum width is 3 51 | caret_width=1 52 | 53 | # set foreground and background colour of indentation guides 54 | indent_guide=indent_guide 55 | 56 | # third argument: if true, use this foreground color. If false, use the default value defined by the filetypes. 57 | # fourth argument: if true, use this background color. If false, use the default value defined by the filetypes. 58 | white_space=white_space 59 | 60 | # style of folding icons, valid values are: 61 | # first argument: 1 for boxes, 2 for circles, 3 for arrows, 4 for +/- 62 | # second argument: 1 for straight lines, 2 for curved lines or 0 for none 63 | folding_style=1;1; 64 | 65 | # should an horizontal line be drawn at the line where text is folded 66 | # 0 to disable 67 | # 1 to draw the line above folded text 68 | # 2 to draw the line below folded text 69 | folding_horiz_line=2 70 | 71 | # first argument: drawing of visual flags to indicate a line is wrapped. This is a bitmask of the 72 | # values: 0 - No visual flags, 1 - Visual flag at end of subline of a wrapped line, 2 - Visual flag 73 | # at begin of subline of a wrapped line, Subline is indented by at least 1 to make room for the flag. 74 | # second argument: whether the visual flags to indicate a line is wrapped are drawn near the border 75 | # or near the text. This is a bitmask of the values: 0 - Visual flags drawn near border, 76 | # 1 - Visual flag at end of subline drawn near text, 2 - Visual flag at begin of subline drawn near text 77 | line_wrap_visuals=1;0; 78 | 79 | # first argument: sets the size of indentation of sublines for wrapped lines in terms of 80 | # the width of a space, only used when the second argument is 0 81 | # second argument: wrapped sublines can be indented to the position of their first subline or 82 | # one more indent level, possible values: 83 | # 0 - Wrapped sublines aligned to left of window plus amount set by the first argument 84 | # 1 - Wrapped sublines are aligned to first subline indent (use the same indentation) 85 | # 2 - Wrapped sublines are aligned to first subline indent plus one more level of indentation 86 | line_wrap_indent=0;1; 87 | 88 | # first argument: amount of space to be drawn above the line's baseline 89 | # second argument: amount of space to be drawn below the line's baseline 90 | line_height=0;0; 91 | 92 | # 3rd argument is true to override default foreground of calltips 93 | # 4th argument is true to override default background of calltips 94 | calltips=call_tips 95 | 96 | [settings] 97 | # which characters should be skipped when moving (or included when deleting) to word boundaries 98 | # should always include space and tab (\s\t) 99 | whitespace_chars=\s\t!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~ 100 | 101 | [named_styles] 102 | # This is the Default "built-in" color scheme 103 | default=0x000033;0xAAAAAA;false;false 104 | error=0xff0000;0xBFBFBF;false;italic 105 | 106 | selection=0x000000;0x808080;false;true 107 | current_line=0x000000;0xCCCCCC;true; 108 | brace_good=0x0000ff;0xFFFFFF;true;false 109 | brace_bad=0xff0000;0xFFFFFF;true;false 110 | margin_line_number=0x000000;0x999999; 111 | margin_folding=0x000000;0x9A9A9A; 112 | fold_symbol_highlight=0xffffff 113 | indent_guide=0xc0c0c0;; 114 | caret=0x000000;0x000000;false; 115 | marker_line=0x000000;0xffff00; 116 | marker_search=0x000000;0x0000f0; 117 | marker_mark=0x000000;0xb8f4b8; 118 | call_tips=0xc0c0c0;0xffffff;false;false 119 | white_space=0xc0c0c0;0xffffff;true;false 120 | 121 | comment=0x993333 122 | comment_doc=0x3f5fbf 123 | comment_line=comment 124 | comment_line_doc=comment_doc 125 | comment_doc_keyword=comment_doc,bold 126 | comment_doc_keyword_error=comment_doc,italic 127 | 128 | number=0x00611F 129 | number_1=number 130 | number_2=number_1 131 | 132 | type=0x0000d0;;true;false 133 | class=type 134 | function=0xFF8080 135 | parameter=function 136 | 137 | keyword=0x05148F;;true;false 138 | keyword_1=keyword 139 | keyword_2=0x823C81;;true;false 140 | keyword_3=0x4972EA 141 | keyword_4=0x4972EA 142 | 143 | identifier=default 144 | identifier_1=identifier 145 | identifier_2=identifier_1 146 | identifier_3=identifier_1 147 | identifier_4=identifier_1 148 | 149 | string=0xff8000 150 | string_1=string 151 | string_2=string_1 152 | string_eol=0x000000;0xe0c0e0;false;false 153 | character=string_1 154 | backticks=string_2 155 | here_doc=string_2 156 | 157 | label=0xFFFFFF 158 | preprocessor=0x341B53 159 | regex=number_1 160 | operator=0x5200B8 161 | decorator=string_1 162 | other=0x404080 163 | 164 | tag=type 165 | tag_unknown=tag,bold 166 | tag_end=tag,bold 167 | attribute=keyword_1 168 | attribute_unknown=attribute,bold 169 | value=string_1 170 | entity=default 171 | 172 | line_added=0x34b034;0xffffff;false;false 173 | line_removed=0xff2727;0xffffff;false;false 174 | line_changed=0x7f007f;0xffffff;false;false 175 | 176 | [build-menu] 177 | FT_00_LB=Compilation 178 | FT_00_CM=./higueulc 179 | FT_00_WD= 180 | EX_00_LB=_Exécuter 181 | EX_00_CM=bash execute.sh 182 | EX_00_WD= 183 | -------------------------------------------------------------------------------- /example/SNES/SNDK/bss_define.egl: -------------------------------------------------------------------------------- 1 | 2 | .bss 0x2100 3 | //SNES PPU 4 | uint8 INIDISP; 5 | uint8 OBJSEL; 6 | uint16 OAMADD; 7 | uint8 OAMDATA; 8 | uint8 BGMODE; 9 | uint8 MOSAIC; 10 | uint8 BG1SC; 11 | uint8 BG2SC; 12 | uint8 BG3SC; 13 | uint8 BG4SC; 14 | uint8 BG12NBA; 15 | uint8 BG34NBA; 16 | uint8 BG1H0FS; 17 | uint8 BG1V0FS; 18 | uint8 BG2H0FS; 19 | uint8 BG2V0FS; 20 | uint8 BG3H0FS; 21 | uint8 BG3V0FS; 22 | uint8 BG4H0FS; 23 | uint8 BG4V0FS; 24 | uint8 VMAINC; 25 | uint16 VMADD; 26 | uint16 VMDATA; 27 | uint8 M7SEL; 28 | uint8 M7A; 29 | uint8 M7B; 30 | uint8 M7C; 31 | uint8 M7D; 32 | uint8 M7X; 33 | uint8 M7Y; 34 | uint8 CGADD; 35 | uint8 CGDATA; 36 | uint8 W12SEL; 37 | uint8 W34SEL; 38 | uint8 WOBJSEL; 39 | uint8 WH0; 40 | uint8 WH1; 41 | uint8 WH2; 42 | uint8 WH3; 43 | uint8 WBGLOG; 44 | uint8 WOBJLOG; 45 | uint8 TM; 46 | uint8 TS; 47 | uint8 TMW; 48 | uint8 TSW; 49 | uint8 CGSWSEL; 50 | uint8 CGADSUB; 51 | uint8 COLDATA; 52 | uint8 SETINI; 53 | uint8 MPYL; 54 | uint8 MPYM; 55 | uint8 MPYH; 56 | uint8 SLHV; 57 | 58 | uint8 OAMDATAREAD; 59 | uint8 VMDATALREAD; 60 | uint8 VMDATAHREAD; 61 | uint8 CGDATAREAD; 62 | 63 | uint8 OPHCT; 64 | uint8 OPVCT; 65 | uint8 STAT77; 66 | uint8 STAT78; 67 | 68 | uint8 APUIO0; 69 | uint8 APUIO1; 70 | uint8 APUIO2; 71 | uint8 APUIO3; 72 | 73 | //WRAM 74 | .bss 0x2180 75 | uint8 WMDATA; 76 | uint16 WMADD; 77 | uint8 WMADDH; 78 | 79 | .bss 0x4016 80 | uint8 JOYSER0; 81 | uint8 JOYSER1; 82 | 83 | .bss 0x4200 84 | //SNES IO 85 | uint8 NMITIMEN; 86 | uint8 WRIO; 87 | uint8 WRMPYA; 88 | uint8 WRMPYB; 89 | 90 | uint8 WRDIVL; 91 | uint8 WRDIVH; 92 | uint8 WRDIVB; 93 | uint8 HTIMEL; 94 | 95 | uint8 HTIMEH; 96 | uint8 VTIMEL; 97 | uint8 VTIMEH; 98 | uint8 MDMAEN; 99 | 100 | uint8 HDMAEN; 101 | uint8 MEMSEL; 102 | 103 | uint8 MEMSEL1; 104 | uint8 MEMSEL2; 105 | 106 | uint8 RDNMI; 107 | uint8 TIMEUP; 108 | uint8 HVBJOY; 109 | uint8 RDIO; 110 | 111 | uint8 RDDIVL; 112 | uint8 RDDIVH; 113 | uint8 RDMPYL; 114 | uint8 RDMPYH; 115 | uint8 STDCONTROL1L; 116 | uint8 STDCONTROL1H; 117 | uint8 STDCONTROL2L; 118 | uint8 STDCONTROL2H; 119 | uint8 STDCONTROL3L; 120 | uint8 STDCONTROL3H; 121 | uint8 STDCONTROL4L; 122 | uint8 STDCONTROL4H; 123 | 124 | //DMA 0 125 | .bss 0x4300 126 | uint8 DMA_0; 127 | uint8 DMA_BADD_0; 128 | uint16 DMA_ADD_0; 129 | uint8 DMA_BANK_0; 130 | uint16 DMA_SIZE_0; 131 | 132 | uint8 HDMA_BANK_0; 133 | uint16 HDMA_ADD_0; 134 | uint8 HDMA_LINE_0; 135 | 136 | //DMA 1 137 | .bss 0x4310 138 | uint8 DMA_1; 139 | uint8 DMA_BADD_1; 140 | uint16 DMA_ADD_1; 141 | uint8 DMA_BANK_1; 142 | uint16 DMA_SIZE_1; 143 | 144 | uint8 HDMA_BANK_1; 145 | uint16 HDMA_ADD_1; 146 | uint8 HDMA_LINE_1; 147 | 148 | 149 | //DMA 2 150 | .bss 0x4320 151 | uint8 DMA_2; 152 | uint8 DMA_BADD_2; 153 | uint16 DMA_ADD_2; 154 | uint8 DMA_BANK_2; 155 | uint16 DMA_SIZE_2; 156 | 157 | uint8 HDMA_BANK_2; 158 | uint16 HDMA_ADD_2; 159 | uint8 HDMA_LINE_2; 160 | 161 | .bss 0x4330 162 | uint8 DMA_3; 163 | uint8 DMA_BADD_3; 164 | uint16 DMA_ADD_3; 165 | uint8 DMA_BANK_3; 166 | uint16 DMA_SIZE_3; 167 | 168 | uint8 HDMA_BANK_3; 169 | uint16 HDMA_ADD_3; 170 | uint8 HDMA_LINE_3; 171 | 172 | .bss 0x4340 173 | uint8 DMA_4; 174 | uint8 DMA_BADD_4; 175 | uint16 DMA_ADD_4; 176 | uint8 DMA_BANK_4; 177 | uint16 DMA_SIZE_4; 178 | 179 | uint8 HDMA_BANK_4; 180 | uint16 HDMA_ADD_4; 181 | uint8 HDMA_LINE_4; 182 | 183 | .bss 0x4350 184 | uint8 DMA_5; 185 | uint8 DMA_BADD_5; 186 | uint16 DMA_ADD_5; 187 | uint8 DMA_BANK_5; 188 | uint16 DMA_SIZE_5; 189 | 190 | uint8 HDMA_BANK_5; 191 | uint16 HDMA_ADD_5; 192 | uint8 HDMA_LINE_5; 193 | 194 | .bss 0x4360 195 | uint8 DMA_6; 196 | uint8 DMA_BADD_6; 197 | uint16 DMA_ADD_6; 198 | uint8 DMA_BANK_6; 199 | uint16 DMA_SIZE_6; 200 | 201 | uint8 HDMA_BANK_6; 202 | uint16 HDMA_ADD_6; 203 | uint8 HDMA_LINE_6; 204 | 205 | .bss 0x4370 206 | uint8 DMA_7; 207 | uint8 DMA_BADD_7; 208 | uint16 DMA_ADD_7; 209 | uint8 DMA_BANK_7; 210 | uint16 DMA_SIZE_7; 211 | 212 | uint8 HDMA_BANK_7; 213 | uint16 HDMA_ADD_7; 214 | uint8 HDMA_LINE_7; 215 | 216 | .bss 0x7ED000 217 | uint8 SNDK_OAM0.x; 218 | uint8 SNDK_OAM0.y; 219 | uint8 SNDK_OAM0.t; 220 | uint8 SNDK_OAM0.a; 221 | 222 | uint8 SNDK_OAM1.x; 223 | uint8 SNDK_OAM1.y; 224 | uint8 SNDK_OAM1.t; 225 | uint8 SNDK_OAM1.a; 226 | 227 | uint8 SNDK_OAM2.x; 228 | uint8 SNDK_OAM2.y; 229 | uint8 SNDK_OAM2.t; 230 | uint8 SNDK_OAM2.a; 231 | 232 | uint8 SNDK_OAM3.x; 233 | uint8 SNDK_OAM3.y; 234 | uint8 SNDK_OAM3.t; 235 | uint8 SNDK_OAM3.a; 236 | 237 | uint8 SNDK_OAML 0x1F0; 238 | uint8 SNDK_OAMH 0x20; 239 | 240 | uint8 SNDK_Bullet.i 14; 241 | uint8 SNDK_Bullet.n 14; 242 | 243 | uint8 SNDK.cpu,SNDK.mcpu,SNDK.pcpu; 244 | uint8 SNDK.clockf,SNDK.clocks,SNDK.clockm,SNDK.clockh; 245 | 246 | uint16 SNDK_BG1Scroll.x; 247 | uint16 SNDK_BG1Scroll.y; 248 | uint16 SNDK_BG2Scroll.x; 249 | uint16 SNDK_BG2Scroll.y; 250 | 251 | //---------------------SPRITE ENGINE---------------------------- 252 | uint16 SNDK_SPRITE.x; 253 | uint16 SNDK_SPRITE.y; 254 | uint16 SNDK_SPRITE.vx; 255 | uint16 SNDK_SPRITE.vy; 256 | 257 | uint16 SNDK_SPRITE.address; 258 | uint16 SNDK_SPRITE.vram; 259 | uint16 SNDK_SPRITE.anim; 260 | uint16 SNDK_SPRITE.visible; 261 | 262 | uint16 SNDK_SPRITE.w; 263 | uint16 SNDK_SPRITE.h; 264 | 265 | uint8 SNDK_SPRITE.t; 266 | uint8 SNDK_SPRITE.a; 267 | uint8 SNDK_SPRITE.oam; 268 | uint8 SNDK_SPRITE.ianim; 269 | 270 | uint8 SNDK_SPRITE.mode; 271 | 272 | uint64 SNDK_SPRITE.reserved2; 273 | uint16 SNDK_SPRITE (0x200-0x20); 274 | 275 | .define SPRITE_ENGINE_MODE0 0x00 //1 sprite 276 | .define SPRITE_ENGINE_MODE1 0x01 //2x2 sprite 277 | 278 | .define SPRITE_ENGINE_MODE2 0x10 //1 sprite Size 279 | .define SPRITE_ENGINE_MODE3 0x11 //2x2 sprite Size 280 | 281 | .define SPRITE_ENGINE_MODE4 0x02 //48x48 sprite (only 16x32) 282 | .define SPRITE_ENGINE_MODE5 0x03 //48x32 sprite (only 16x32) 283 | 284 | .define SPRITE_ENGINE_MODE6 0x04 //custom sprite 285 | .define SPRITE_ENGINE_MODE7 0x05 //custom sprite x2 286 | //-------------------------------------- 287 | uint8 SNDK_BUF_BG1.h 0x40; 288 | uint8 SNDK_BUF_BG1.v 0x40; 289 | 290 | uint8 SNDK_BUF_BG2.h 0x40; 291 | uint8 SNDK_BUF_BG2.v 0x40; 292 | 293 | uint8 SNDK_Bullet.x 128; 294 | uint8 SNDK_Bullet.y 128; 295 | uint8 SNDK_Bullet.vx 128; 296 | uint8 SNDK_Bullet.vy 128; 297 | uint8 SNDK_BG3.t1; 298 | uint8 SNDK_BG3.t2 0x800; 299 | 300 | uint8 SNDK_PALBG0 0x20; 301 | uint8 SNDK_PALBG1 0x20; 302 | uint8 SNDK_PALBG2 0x20; 303 | uint8 SNDK_PALBG3 0x20; 304 | 305 | uint8 SNDK_PALBG4 0x20; 306 | uint8 SNDK_PALBG5 0x20; 307 | uint8 SNDK_PALBG6 0x20; 308 | uint8 SNDK_PALBG7 0x20; 309 | 310 | uint8 SNDK_PALSPR0 0x20; 311 | uint8 SNDK_PALSPR1 0x20; 312 | uint8 SNDK_PALSPR2 0x20; 313 | uint8 SNDK_PALSPR3 0x20; 314 | 315 | uint8 SNDK_PALSPR4 0x20; 316 | uint8 SNDK_PALSPR5 0x20; 317 | uint8 SNDK_PALSPR6 0x20; 318 | uint8 SNDK_PALSPR7 0x20; 319 | 320 | 321 | 322 | .bss 0x7F0000 323 | uint8 SNDK_BufferBG1 0x4000; 324 | uint8 SNDK_BufferBG2 0x4000; 325 | uint8 SNDK_BufferCOL 0x2000; 326 | 327 | uint8 SNDK_BufferSPR1 0x2000; 328 | uint8 SNDK_BufferSPR2 0x2000; 329 | uint8 SNDK_BufferSPR3 0x2000; 330 | 331 | .macro SNDK_SPR_META 332 | SNDK_SPR_SIZE = .arg1; 333 | SNDK_SPR_SIZET = (.arg1>>3); 334 | .endmacro 335 | .bss 0x100 336 | uint8 SNDK_MEMSET; 337 | .bss 0xC0 338 | uint8 SNDK_SPR_SIZE; 339 | uint8 SNDK_SPR_SIZET; 340 | 341 | .bss 0x7E2000 342 | 343 | //-------------- 344 | 345 | .define OAM_XFLIP 0x80 346 | .define OAM_YFLIP 0x40 347 | .define OAM_PRIO0 0x00 348 | .define OAM_PRIO1 0x10 349 | .define OAM_PRIO2 0x20 350 | .define OAM_PRIO3 0x30 351 | .define OAM_PAL0 0x00 352 | .define OAM_PAL1 0x02 353 | .define OAM_PAL2 0x04 354 | .define OAM_PAL3 0x06 355 | .define OAM_PAL4 0x08 356 | .define OAM_PAL5 0x0A 357 | .define OAM_PAL6 0x0C 358 | .define OAM_PAL7 0x0E 359 | .define OAM_TILE 0x01 360 | 361 | .define OAM_SIZE 0xAA 362 | 363 | .define SNDK_PAD_B 0x80 364 | .define SNDK_PAD_Y 0x40 365 | .define SNDK_PAD_START 0x20 366 | .define SNDK_PAD_SELECT 0x10 367 | .define SNDK_PAD_UP 0x08 368 | .define SNDK_PAD_DOWN 0x04 369 | .define SNDK_PAD_LEFT 0x02 370 | .define SNDK_PAD_RIGHT 0x01 371 | 372 | .define SNDK_PAD_A 0x80 373 | .define SNDK_PAD_X 0x40 374 | .define SNDK_PAD_L 0x20 375 | .define SNDK_PAD_R 0x10 376 | 377 | .define SNDK_MODE1 0x39 // BG 1 & 2 16x16, BG 3 8x8,mode 1 , BG 3 pri 378 | .define SNDK_MODE7 0x07 379 | 380 | .define SNDK_FONTPAL0 0x20 381 | .define SNDK_FONTPAL1 0x24 382 | .define SNDK_FONTPAL2 0x28 383 | .define SNDK_FONTPAL3 0x2C 384 | 385 | //0,2,6, $6000 address Sprite 386 | .define SNDK_SPR_8_16 0x03 387 | .define SNDK_SPR_8_32 0x23 388 | .define SNDK_SPR_16_32 0x63 389 | 390 | .define MODE8 asm "sep #$20"; 391 | .define MODE16 asm "rep #$20"; 392 | 393 | .define SPR_INDEX_0 0x00 394 | .define SPR_INDEX_1 0x20 395 | .define SPR_INDEX_2 0x40 396 | .define SPR_INDEX_3 0x60 397 | 398 | .define SPR_INDEX_4 0x80 399 | .define SPR_INDEX_5 0xA0 400 | .define SPR_INDEX_6 0xC0 401 | .define SPR_INDEX_7 0xE0 402 | 403 | .define SPR_INDEX_8 0x100 404 | .define SPR_INDEX_9 0x120 405 | .define SPR_INDEX_10 0x140 406 | .define SPR_INDEX_11 0x160 407 | 408 | .define SPR_INDEX_12 0x180 409 | .define SPR_INDEX_13 0x1A0 410 | .define SPR_INDEX_14 0x1C0 411 | .define SPR_INDEX_15 0x1E0 412 | -------------------------------------------------------------------------------- /src/Eagle_asm_AltairX.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | static void asm_address(const EAGLE_VARIABLE &src,std::string &labelp,const std::string &pregister,std::string &srcvalue,std::string &str_code); 13 | 14 | void Eagle::asm_bru_AltairX(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 15 | { 16 | 17 | } 18 | 19 | void Eagle::asm_call_jump_AltairX(const EAGLE_VARIABLE &src,int ninst,int type) 20 | { 21 | 22 | } 23 | 24 | void Eagle::asm_return_AltairX(const EAGLE_VARIABLE &ret,bool retvoid) 25 | { 26 | if(retvoid == true) 27 | { 28 | this->text_code += "ret\n"; 29 | }else 30 | { 31 | if(ret.type == EAGLE_keywords::IDX) 32 | { 33 | this->text_code += "move acc,t1\n"; 34 | } 35 | 36 | if(ret.type == EAGLE_keywords::IDY) 37 | { 38 | this->text_code += "move acc,t2\n"; 39 | } 40 | 41 | 42 | if(ret.type != EAGLE_keywords::ACC) 43 | { 44 | if(ret.bimm == true) 45 | { 46 | this->text_code += "movei a0,"+ std::to_string(ret.immediate&0x3FFFF) +"\n"; 47 | } 48 | else 49 | { 50 | this->text_code += "ldi.p t0,"+ std::to_string(ret.address&0x3FF) +",[rz]\n"; 51 | this->text_code += "moveix "+ std::to_string(ret.address&0xFFFFFF00) +"\n"; 52 | this->text_code += "move acc,t0\n"; 53 | } 54 | } 55 | 56 | this->text_code += "ret\n"; 57 | 58 | } 59 | } 60 | 61 | void Eagle::asm_alu_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 62 | { 63 | std::string mnemonic; 64 | std::string src1value; 65 | std::string src2value; 66 | std::string dstvalue; 67 | 68 | std::string str_code1,str_code2; 69 | 70 | bool PQope = false; 71 | 72 | uint64_t adrl; 73 | uint64_t adrh = 0; 74 | 75 | 76 | asm_address(src1,this->label1,"t1",src1value,this->text_code); 77 | asm_address(src2,this->label2,"t2",src2value,this->text_code); 78 | 79 | 80 | if(operator1 == '+') 81 | mnemonic = "add"; 82 | 83 | if(operator1 == '-') 84 | mnemonic = "sub"; 85 | 86 | if(operator1 == '&') 87 | mnemonic = "and"; 88 | 89 | if(operator1 == '|') 90 | mnemonic = "ora"; 91 | 92 | if(operator1 == '^') 93 | mnemonic = "eor"; 94 | 95 | if(operator1 == '<') 96 | mnemonic = "asl"; 97 | 98 | if(operator1 == '>') 99 | mnemonic = "lsr"; 100 | 101 | if(operator1 == '*') 102 | mnemonic = "mul"; 103 | 104 | if(operator1 == '/') 105 | mnemonic = "div"; 106 | 107 | if(operator1 == '%') 108 | mnemonic = "div"; 109 | //--------------- 110 | bool dst_other = false; 111 | if(dst.type2 == EAGLE_keywords::REGISTER) 112 | { 113 | if(dst.address < 8) 114 | dstvalue = "t" + std::to_string(dst.address+3); 115 | else 116 | dstvalue = "s" + std::to_string(dst.address-8); 117 | }else 118 | if(dst.type == EAGLE_keywords::IDX) 119 | { 120 | dstvalue = "t1"; 121 | }else 122 | if(dst.type == EAGLE_keywords::IDY) 123 | { 124 | dstvalue = "t2"; 125 | }else 126 | if(dst.type == EAGLE_keywords::ACC) 127 | { 128 | dstvalue = "acc"; 129 | }else 130 | { 131 | dstvalue = "t0"; 132 | dst_other = true; 133 | } 134 | 135 | if( (dst.type == EAGLE_keywords::UINT8) || (dst.type == EAGLE_keywords::INT8)) 136 | mnemonic += ".b"; 137 | 138 | if( (dst.type == EAGLE_keywords::UINT16) || (dst.type == EAGLE_keywords::INT16)) 139 | mnemonic += ".w"; 140 | 141 | if( (dst.type == EAGLE_keywords::UINT32) || (dst.type == EAGLE_keywords::INT32)) 142 | mnemonic += ".l"; 143 | 144 | if( (dst.type == EAGLE_keywords::UINT64) || (dst.type == EAGLE_keywords::INT64)) 145 | mnemonic += ".q"; 146 | 147 | 148 | if(src2.bimm == true) 149 | { 150 | adrl = dst.address &0xFF; 151 | adrh = (dst.address &0xFFFFFF00)>>8; 152 | src2value = std::to_string(adrl); 153 | if(adrh > 0) 154 | mnemonic += "p"; 155 | } 156 | 157 | 158 | mnemonic += " "; 159 | 160 | 161 | if(operator1 == '*') 162 | { 163 | this->text_code += mnemonic + src1value + "," + src2value +"\n"; 164 | this->text_code += "move " + dstvalue + ",PL\n"; 165 | PQope = true; 166 | } 167 | 168 | if(operator1 == '/') 169 | { 170 | this->text_code += mnemonic + src1value + "," + src2value +"\n"; 171 | this->text_code += "move " + dstvalue + ",Q\n"; 172 | PQope = true; 173 | } 174 | 175 | if(operator1 == '%') 176 | { 177 | this->text_code += mnemonic + src1value + "," + src2value +"\n"; 178 | this->text_code += "move " + dstvalue + ",QR\n"; 179 | PQope = true; 180 | } 181 | 182 | 183 | if(operator1 == '=') 184 | { 185 | this->text_code += "ori " + dstvalue + "," + src2value +",0\n"; 186 | }else 187 | { 188 | if(PQope == false) 189 | this->text_code += mnemonic + dstvalue + "," + src1value +"," + src2value+"\n"; 190 | } 191 | 192 | if(src2.bimm == true) 193 | { 194 | if(adrh > 0) 195 | this->text_code += "moveix "+ std::to_string(adrh) +"\n"; 196 | } 197 | 198 | if(dst_other == false) 199 | return; 200 | 201 | 202 | 203 | if( (dst.type == EAGLE_keywords::UINT8) || (dst.type == EAGLE_keywords::INT8)) 204 | mnemonic = "sti.bp "; 205 | 206 | if( (dst.type == EAGLE_keywords::UINT16) || (dst.type == EAGLE_keywords::INT16)) 207 | mnemonic = "sti.wp "; 208 | 209 | if( (dst.type == EAGLE_keywords::UINT32) || (dst.type == EAGLE_keywords::INT32)) 210 | mnemonic = "sti.lp "; 211 | 212 | if( (dst.type == EAGLE_keywords::UINT64) || (dst.type == EAGLE_keywords::INT64)) 213 | mnemonic = "sti.qp "; 214 | 215 | if(dst.bptr == false) 216 | { 217 | adrl = dst.address &0xFF; 218 | adrh = (dst.address &0xFFFFFF00)>>8; 219 | 220 | this->text_code += mnemonic + "t0," + std::to_string(adrl) + "[rz]\n"; 221 | this->text_code += "moveix "+ std::to_string(adrh) +"\n"; 222 | } 223 | else 224 | { 225 | 226 | } 227 | } 228 | 229 | void Eagle::asm_falu_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 230 | { 231 | 232 | } 233 | 234 | 235 | static void asm_address(const EAGLE_VARIABLE &src,std::string &labelp,const std::string &pregister,std::string &srcvalue,std::string &str_code) 236 | { 237 | 238 | if(src.bptr == false) 239 | { 240 | if(src.blabel == true) 241 | { 242 | 243 | if(src.token1 == '$') 244 | srcvalue = labelp; 245 | else 246 | { 247 | srcvalue = pregister; 248 | //str_code = "ld t0," + labelp 249 | } 250 | 251 | }else 252 | { 253 | srcvalue = std::to_string(src.address); 254 | 255 | if(src.token1 == '$') 256 | srcvalue = std::to_string(src.address&0xFFFF); 257 | 258 | if(src.type2 == EAGLE_keywords::REGISTER) 259 | { 260 | if(src.address < 8) 261 | srcvalue = "t" + std::to_string(src.address+3); 262 | else 263 | srcvalue = "s" + std::to_string(src.address-8); 264 | }else 265 | if(src.type == EAGLE_keywords::IDX) 266 | { 267 | srcvalue = "t1"; 268 | }else 269 | if(src.type == EAGLE_keywords::IDY) 270 | { 271 | srcvalue = "t2"; 272 | }else 273 | if(src.type == EAGLE_keywords::ACC) 274 | { 275 | srcvalue = "acc"; 276 | } 277 | 278 | } 279 | 280 | 281 | } 282 | else 283 | { 284 | bool py = false; 285 | bool px = false; 286 | 287 | //arg2 288 | if(src.ptr2.bimm == true) 289 | { 290 | str_code += "ldx #" + std::to_string(src.ptr2.value&0xFFFF) +"\n"; 291 | px = true; 292 | }else 293 | { 294 | if(src.ptr2.type == EAGLE_keywords::IDX) 295 | { 296 | px = true; 297 | }else 298 | if(src.ptr2.type == EAGLE_keywords::IDY) 299 | { 300 | py = true; 301 | }else 302 | if(src.ptr2.type == EAGLE_keywords::ACC) 303 | { 304 | px = true; 305 | str_code += "tax\n"; 306 | }else 307 | if(src.ptr2.type != EAGLE_keywords::UNKNOW) 308 | { 309 | px = true; 310 | str_code += "lda " + std::to_string(src.ptr2.value) +"\n"; 311 | str_code += "tax\n"; 312 | } 313 | } 314 | 315 | //arg1 316 | if(src.ptr1.bimm == true) 317 | { 318 | srcvalue = std::to_string(src.ptr1.value); 319 | 320 | }else 321 | { 322 | srcvalue = "("+ pregister + ")"; 323 | 324 | if(src.ptr1.type == EAGLE_keywords::IDX) 325 | { 326 | str_code += "stx "+ pregister +"\n"; 327 | }else 328 | if(src.ptr1.type == EAGLE_keywords::IDY) 329 | { 330 | str_code += "sty "+ pregister +"\n"; 331 | }else 332 | if(src.ptr1.type == EAGLE_keywords::ACC) 333 | { 334 | str_code += "sta "+ pregister +"\n"; 335 | }else 336 | { 337 | if(src.ptr1.token2 == ':') 338 | { 339 | srcvalue = labelp; 340 | if(src.ptr1.token1 == '$') 341 | srcvalue = "#" + labelp; 342 | 343 | if(src.ptr1.token1 == '#') 344 | srcvalue = "#:" + labelp; 345 | }else 346 | { 347 | srcvalue = std::to_string(src.ptr1.value); 348 | 349 | if(src.ptr1.token1 == '$') 350 | srcvalue = "#" + std::to_string(src.ptr1.value&0xFFFF); 351 | 352 | if(src.ptr1.token1 == '#') 353 | srcvalue = "#:" + std::to_string(src.ptr1.value>>16); 354 | } 355 | } 356 | } 357 | 358 | if(src.ptr2_exist == true) 359 | { 360 | if(px == true) 361 | srcvalue += ",X"; 362 | 363 | if(py == true) 364 | srcvalue += ",Y"; 365 | } 366 | } 367 | 368 | if(src.token1 == '@') 369 | srcvalue = "[" + srcvalue + "]"; 370 | 371 | if(src.token2 == '@') 372 | srcvalue = "(" + srcvalue + ")"; 373 | } 374 | 375 | -------------------------------------------------------------------------------- /src/Eagle.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "Eagle_enum.hpp" 5 | #include "Eagle_struct.hpp" 6 | #include "CPU_Z80.hpp" 7 | 8 | class Eagle_func 9 | { 10 | public: 11 | std::string name; 12 | 13 | EAGLE_keywords type; 14 | int narg; 15 | int alloc; 16 | uint64_t address; 17 | 18 | int begid; 19 | int endid; 20 | bool retauto; 21 | 22 | void clear(void) 23 | { 24 | this->narg = 0; 25 | this->type = EAGLE_keywords::UNKNOW; 26 | this->alloc = 0; 27 | this->address = 0; 28 | 29 | this->begid = 0; 30 | this->endid = 0; 31 | this->retauto = true; 32 | } 33 | }; 34 | 35 | typedef struct 36 | { 37 | bool exist; 38 | bool macro; 39 | std::string text; 40 | std::string arg[8]; 41 | 42 | }EAGLE_DEFINE; 43 | 44 | typedef struct 45 | { 46 | std::string item; 47 | int64_t value; 48 | int type; 49 | 50 | char token0,token1,token2; 51 | 52 | 53 | }EAGLE_MNEMONIQUE; 54 | 55 | class Eagle 56 | { 57 | public: 58 | Eagle(void); 59 | void parser_word(void); 60 | void load_file(const char *path); 61 | void write_file(const char *path,std::string text); 62 | void write_file_bin(const char *path); 63 | void out_asm(void); 64 | 65 | void bin_6502(void); 66 | void bin_65816(void); 67 | void bin_AltairX(void); 68 | void bin_80286(void); 69 | void bin_z80(void); 70 | 71 | std::string text_code; 72 | std::string filename,mesen_ram,mesen_rom,str_bra; 73 | bool debug,bout_asm,bcycle,bmesen,snes_checksum; 74 | int error; 75 | int target; 76 | 77 | private: 78 | bool isWord(char c); 79 | bool isOperator(char c,char c2,int &i); 80 | bool isNumber(char c); 81 | bool isAlphabetic(char c); 82 | 83 | bool isOperator_move(char c,char c2); 84 | bool isOperator_cmp(char c,char c2); 85 | bool isOperator_calcul(char c,char c2); 86 | 87 | int isComment(char c1,char c2,int i); 88 | int isText(char c1,int i,EAGLE_WORDS &tword); 89 | int isConstantFolding(char c1,int i,EAGLE_WORDS &tword); 90 | void out_error(const EAGLE_WORDS tword,const std::string text); 91 | void load_file_bin(const char *path,std::vector &data); 92 | 93 | uint64_t alloc(EAGLE_keywords type,int n); 94 | 95 | bool gvariable_exist(std::string &tmp,EAGLE_VARIABLE &var); 96 | bool variable_exist(std::string &tmp,EAGLE_VARIABLE &var); 97 | 98 | bool define_exist(std::string &tmp); 99 | bool keywords_exist(std::string &tmp); 100 | bool label_exist(std::string &tmp); 101 | bool labelbin_exist(std::string &tmp); 102 | 103 | //---------ALL-------------- 104 | void asm_return(const EAGLE_VARIABLE &ret,bool retvoid); 105 | void asm_alu(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 106 | void asm_falu(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 107 | 108 | void asm_bru(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 109 | void asm_call_jump(const EAGLE_VARIABLE &var,int narg,int type); 110 | 111 | void asm_do_else(void); 112 | 113 | //---------65816-------------- 114 | void asm_return_65816(const EAGLE_VARIABLE &ret,bool retvoid); 115 | void asm_alu_65816(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 116 | 117 | void asm_bru_65816(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 118 | void asm_call_jump_65816(const EAGLE_VARIABLE &var,int narg,int type); 119 | 120 | //---------6502-------------- 121 | void asm_return_6502(const EAGLE_VARIABLE &ret,bool retvoid); 122 | void asm_alu_6502(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 123 | 124 | void asm_bru_6502(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 125 | void asm_call_jump_6502(const EAGLE_VARIABLE &var,int narg,int type); 126 | 127 | //---------80186-------------- 128 | void asm_return_80186(const EAGLE_VARIABLE &ret,bool retvoid); 129 | void asm_alu_80186(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 130 | 131 | void asm_bru_80186(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 132 | void asm_call_jump_80186(const EAGLE_VARIABLE &var,int narg,int type); 133 | 134 | //---------z80-------------- 135 | void asm_return_z80(const EAGLE_VARIABLE &ret,bool retvoid); 136 | void asm_alu_z80(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 137 | 138 | void asm_bru_z80(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 139 | void asm_call_jump_z80(const EAGLE_VARIABLE &var,int narg,int type); 140 | std::string asm_z80_arg(const EAGLE_VARIABLE &src,int &type,std::string &labelp); 141 | 142 | //---------AltairX-------------- 143 | void asm_return_AltairX(const EAGLE_VARIABLE &ret,bool retvoid); 144 | void asm_alu_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 145 | void asm_falu_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2); 146 | 147 | void asm_mul_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2); 148 | void asm_div_AltairX(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2); 149 | 150 | void asm_bru_AltairX(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel); 151 | void asm_call_jump_AltairX(const EAGLE_VARIABLE &var,int narg,int type); 152 | 153 | bool variable_exist(EAGLE_WORDS tword,EAGLE_VARIABLE &var,int elabel); 154 | 155 | void convertStringToNumber(std::string str,int64_t &result,double &dresult); 156 | 157 | int line_code_asm(int mode); 158 | 159 | std::map keywords; 160 | std::map variable; 161 | std::map gvariable; 162 | std::map label; 163 | 164 | 165 | std::map define; 166 | 167 | std::vector> instructions; 168 | std::vector mnemonic; 169 | 170 | std::string kmacro[8]; 171 | 172 | std::string filetext; 173 | std::vector filebin; 174 | std::map labelbin; 175 | 176 | std::string label0,label1,label2,labelarg[8],cyclew,labelcall; 177 | std::string mesen; 178 | 179 | EAGLE_VARIABLE arg[8]; 180 | int mmap,varsize; 181 | int cycle; 182 | EAGLE_DEFINE tmacro; 183 | 184 | 185 | uint64_t idf,sizebin,offset; 186 | 187 | int line,col; 188 | int func_alloc; 189 | int mode_alloc; 190 | int ilabel; 191 | 192 | uint64_t func_address; 193 | uint64_t wram_address; 194 | 195 | uint64_t spm_address; 196 | uint64_t lib_address; 197 | uint64_t funcspm_address; 198 | uint64_t funclib_address; 199 | 200 | uint64_t spm_init; 201 | uint64_t lib_init; 202 | uint64_t funcspm_init; 203 | uint64_t funclib_init; 204 | 205 | int register_address; 206 | uint64_t stack_address; 207 | 208 | int scope_label[128]; 209 | int snesromfree; 210 | }; 211 | 212 | class Constant_folding 213 | { 214 | public: 215 | 216 | static const int CAPACITY = 64; 217 | 218 | Constant_folding(); 219 | void evaluate(const std::string &text); 220 | void display(); 221 | 222 | int64_t result; 223 | double fresult; 224 | 225 | private: 226 | 227 | double fstack[Constant_folding::CAPACITY]; 228 | int64_t stack[Constant_folding::CAPACITY]; 229 | char operators[Constant_folding::CAPACITY]; 230 | 231 | 232 | int8_t stack_top; 233 | int8_t operator_top; 234 | int8_t stack_capacity; 235 | bool hexa,integer; 236 | std::string text; 237 | 238 | //--- 239 | bool isFull(); 240 | bool isEmpty(); 241 | void push(int64_t item,double fitem); 242 | int64_t pop(); 243 | 244 | bool isFull_operator(); 245 | bool isEmpty_operator(); 246 | void push_operator(char c); 247 | char pop_operator(); 248 | char peek_operator(); 249 | char precedence(char ope); 250 | 251 | bool isOperator(char c); 252 | bool isNumber(char c); 253 | bool isNumberDec(char c); 254 | bool isNumberBin(char c); 255 | bool isNumberHex(char c); 256 | int64_t applyOperation(int64_t a, int64_t b, char op); 257 | double fapplyOperation(double a, double b, char op); 258 | 259 | void apply_operation(); 260 | }; 261 | 262 | enum 263 | { 264 | ALLOC_UNK, 265 | ALLOC_WRAM, 266 | ALLOC_SPM, 267 | ALLOC_FRAM, 268 | ALLOC_FSPM, 269 | ALLOC_FLIB, 270 | ALLOC_REGISTER, 271 | ALLOC_STACK, 272 | ALLOC_LIB, 273 | }; 274 | 275 | enum 276 | { 277 | TARGET_UNK, 278 | 279 | TARGET_AltairX, 280 | 281 | TARGET_6502, 282 | TARGET_65C02, 283 | TARGET_HuC6520, 284 | TARGET_65816, 285 | 286 | TARGET_Z80, 287 | 288 | TARGET_80286, 289 | TARGET_C, 290 | 291 | TARGET_RV32, 292 | }; 293 | enum 294 | { 295 | TYPE_UNK, 296 | TYPE_NUMBER, 297 | TYPE_WORD, 298 | TYPE_OPERATOR, 299 | TYPE_DATASTR, 300 | TYPE_CONSTANT, 301 | TYPE_LABEL, 302 | TYPE_PTR, 303 | TYPE_END, 304 | }; 305 | -------------------------------------------------------------------------------- /src/constant_folding.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | class Constant_folding 7 | { 8 | public: 9 | 10 | static const int CAPACITY = 64; 11 | 12 | Constant_folding(); 13 | void evaluate(const std::string &expression); 14 | void display(); 15 | 16 | int64_t result; 17 | double fresult; 18 | 19 | private: 20 | 21 | double fstack[Constant_folding::CAPACITY]; 22 | int64_t stack[Constant_folding::CAPACITY]; 23 | char operators[Constant_folding::CAPACITY]; 24 | 25 | 26 | int8_t stack_top; 27 | int8_t operator_top; 28 | int8_t stack_capacity; 29 | bool hexa,integer; 30 | std::string text; 31 | 32 | //--- 33 | bool isFull(); 34 | bool isEmpty(); 35 | void push(int64_t item,double fitem); 36 | int64_t pop(); 37 | 38 | bool isFull_operator(); 39 | bool isEmpty_operator(); 40 | void push_operator(char c); 41 | char pop_operator(); 42 | char peek_operator(); 43 | char precedence(char ope); 44 | 45 | bool isOperator(char c); 46 | bool isNumber(char c); 47 | bool isNumberDec(char c); 48 | bool isNumberBin(char c); 49 | bool isNumberHex(char c); 50 | int64_t applyOperation(int64_t a, int64_t b, char op); 51 | double fapplyOperation(double a, double b, char op); 52 | 53 | void apply_operation(); 54 | }; 55 | 56 | Constant_folding::Constant_folding() 57 | { 58 | this->stack_top = -1; 59 | this->operator_top = -1; 60 | this->stack_capacity = Constant_folding::CAPACITY; 61 | this->hexa = false; 62 | this->result = 0; 63 | this->fresult = 0; 64 | this->text.reserve(256); 65 | this->integer = true; 66 | 67 | for(uint32_t i = 0;i < Constant_folding::CAPACITY;i++) 68 | { 69 | this->stack[i] = 0; 70 | this->fstack[i] = 0; 71 | this->operators[i] = 0; 72 | } 73 | } 74 | 75 | //----------------------- 76 | 77 | bool Constant_folding::isFull() 78 | { 79 | return this->stack_top == this->stack_capacity - 1; 80 | } 81 | 82 | bool Constant_folding::isEmpty() 83 | { 84 | return this->stack_top == -1; 85 | } 86 | 87 | void Constant_folding::push(int64_t item,double fitem) 88 | { 89 | if (this->isFull()) return; 90 | this->stack_top++; 91 | this->fstack[this->stack_top] = fitem; 92 | this->stack[this->stack_top] = item; 93 | } 94 | 95 | int64_t Constant_folding::pop() 96 | { 97 | if(isEmpty()) return 0; 98 | this->fresult = this->fstack[this->stack_top]; 99 | this->result = this->stack[this->stack_top]; 100 | this->stack_top--; 101 | return this->result; 102 | } 103 | 104 | 105 | //----------------------- 106 | 107 | bool Constant_folding::isFull_operator() 108 | { 109 | return this->operator_top == this->stack_capacity - 1; 110 | } 111 | 112 | bool Constant_folding::isEmpty_operator() 113 | { 114 | return this->operator_top == -1; 115 | } 116 | 117 | void Constant_folding::push_operator(char item) 118 | { 119 | if (this->isFull_operator()) return; 120 | this->operators[++this->operator_top] = item; 121 | } 122 | 123 | char Constant_folding::pop_operator() 124 | { 125 | if(isEmpty_operator()) return 0; 126 | return this->operators[this->operator_top--]; 127 | } 128 | 129 | char Constant_folding::peek_operator() 130 | { 131 | if(isEmpty()) return -1; 132 | return this->operators[this->operator_top]; 133 | } 134 | 135 | //----------------------- 136 | 137 | bool Constant_folding::isOperator(char c) 138 | { 139 | return c == '+' || c == '-' || c == '*' || c == '/' || c == '&' || c == '|' || c == '^' || c == 1 || c == 2; 140 | } 141 | 142 | bool Constant_folding::isNumber(char c) 143 | { 144 | if(this->hexa == false) 145 | return (c >= '0' && c <= '9') || (c == '.'); 146 | else 147 | return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); 148 | } 149 | 150 | bool Constant_folding::isNumberDec(char c) 151 | { 152 | return (c >= '0' && c <= '9') || (c == '.'); 153 | } 154 | 155 | bool Constant_folding::isNumberBin(char c) 156 | { 157 | return c == '0' || c == '1'; 158 | } 159 | 160 | 161 | bool Constant_folding::isNumberHex(char c) 162 | { 163 | return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); 164 | } 165 | 166 | //----------------------- 167 | 168 | char Constant_folding::precedence(char op) 169 | { 170 | switch (op) 171 | { 172 | case '+': 173 | case '-': 174 | return 1; 175 | 176 | case 1: 177 | case 2: 178 | case '&': 179 | case '|': 180 | case '^': 181 | return 3; 182 | 183 | case '*': 184 | case '/': 185 | return 2; 186 | 187 | default: 188 | return 0; 189 | } 190 | } 191 | 192 | int64_t Constant_folding::applyOperation(int64_t a, int64_t b, char op) 193 | { 194 | switch (op) 195 | { 196 | case 1: 197 | return a << b; 198 | case 2: 199 | return a >> b; 200 | case '+': 201 | return a + b; 202 | case '-': 203 | return a - b; 204 | case '*': 205 | return a * b; 206 | case '/': 207 | return a / b; 208 | case '&': 209 | return a & b; 210 | case '|': 211 | return a | b; 212 | case '^': 213 | return a ^ b; 214 | } 215 | return 0; 216 | } 217 | 218 | double Constant_folding::fapplyOperation(double a, double b, char op) 219 | { 220 | switch (op) 221 | { 222 | case 1: 223 | return (int64_t)a << (int64_t)b; 224 | case 2: 225 | return (int64_t)a >> (int64_t)b; 226 | case '+': 227 | return a + b; 228 | case '-': 229 | return a - b; 230 | case '*': 231 | return a * b; 232 | case '/': 233 | return a / b; 234 | case '&': 235 | return (int64_t)a & (int64_t)b; 236 | case '|': 237 | return (int64_t)a | (int64_t)b; 238 | case '^': 239 | return (int64_t)a ^ (int64_t)b; 240 | } 241 | return 0; 242 | } 243 | 244 | void Constant_folding::apply_operation() 245 | { 246 | int64_t b = this->pop(); 247 | double fb = this->fresult; 248 | int64_t a = this->pop(); 249 | double fa = this->fresult; 250 | char op = this->pop_operator(); 251 | this->push(this->applyOperation(a, b, op),this->fapplyOperation(fa, fb, op)); 252 | } 253 | 254 | //----------------------- 255 | 256 | static std::string formatExpression(const std::string& expression) 257 | { 258 | std::string result; 259 | for (char c : expression) 260 | { 261 | if(c == '-') 262 | { 263 | result += " "; 264 | result += c; 265 | result += " "; 266 | } 267 | else 268 | { 269 | result += c; 270 | } 271 | } 272 | return result; 273 | } 274 | 275 | void Constant_folding::evaluate(const std::string &expression) 276 | { 277 | //std::string expression = formatExpression(in_expression); 278 | 279 | int n = expression.size(); 280 | char str_float[64]; 281 | bool hexadecimal,binary; 282 | 283 | this->text = ""; 284 | 285 | for (int i = 0; i < n; ++i) 286 | { 287 | char letter = expression[i]; 288 | if ( (expression[i] == '<') && (expression[i + 1] == '<') ) 289 | letter = 1; 290 | 291 | if ( (expression[i] == '>') && (expression[i + 1] == '>') ) 292 | letter = 2; 293 | 294 | if ( (expression[i] == '0') && (expression[i + 1] == 'x') ) 295 | letter = 3; 296 | 297 | if ( (expression[i] == '0') && (expression[i + 1] == 'b') ) 298 | letter = 4; 299 | 300 | if(letter < 5) 301 | i++; 302 | 303 | this->text += letter; 304 | } 305 | this->text += " "; 306 | 307 | n = text.size(); 308 | 309 | for (int i = 0; i < n; ++i) 310 | { 311 | hexadecimal = false; 312 | binary = false; 313 | 314 | if(text[i] == 3) 315 | { 316 | hexadecimal = true; 317 | i++; 318 | } 319 | 320 | if(text[i] == 4) 321 | { 322 | binary = true; 323 | i++; 324 | } 325 | 326 | this->hexa = hexadecimal; 327 | 328 | if (text[i] == ' ') 329 | continue; 330 | 331 | if (isNumber(text[i]) || (text[i] == '-' && isNumber(text[i + 1]))) 332 | { 333 | int number = 0,l = 0; 334 | bool isNegative = false; 335 | double fnumber = 0; 336 | 337 | if(text[i] == '-') 338 | { 339 | isNegative = true; 340 | i++; 341 | } 342 | 343 | if( (binary == false) && (hexadecimal == false) ) 344 | { 345 | while (i < n && isNumberDec(text[i])) 346 | { 347 | if(text[i] == '.') 348 | this->integer = false; 349 | 350 | number = number * 10 + (text[i] - '0'); 351 | str_float[l] = text[i]; 352 | l++; 353 | i++; 354 | } 355 | i--; 356 | str_float[l] = 0; 357 | 358 | 359 | 360 | fnumber = atof(str_float); 361 | } 362 | 363 | if(binary == true) 364 | { 365 | while (i < n && isNumberBin(text[i])) 366 | { 367 | number = number * 2 + (text[i] - '0'); 368 | i++; 369 | } 370 | i--; 371 | 372 | fnumber = number; 373 | } 374 | 375 | if(hexadecimal == true) 376 | { 377 | while (i < n && isNumberHex(text[i])) 378 | { 379 | char value = text[i] - '0'; 380 | char c = text[i]; 381 | 382 | if( (c >= 'a' && c <= 'f') ) 383 | value = text[i] - 'a' + 10; 384 | 385 | if( (c >= 'A' && c <= 'F') ) 386 | value = text[i] - 'A' + 10; 387 | 388 | number = number * 16 + value; 389 | i++; 390 | } 391 | i--; 392 | 393 | fnumber = number; 394 | } 395 | 396 | if(isNegative == true) 397 | { 398 | number = -number; 399 | fnumber = -fnumber; 400 | } 401 | 402 | binary = false; 403 | hexadecimal = false; 404 | 405 | this->push(number,fnumber); 406 | } 407 | else if (text[i] == '(') 408 | { 409 | this->push_operator(text[i]); 410 | } 411 | else if (text[i] == ')') 412 | { 413 | while (!this->isEmpty_operator() && this->peek_operator() != '(') 414 | { 415 | this->apply_operation(); 416 | } 417 | if (!this->isEmpty_operator() && this->peek_operator() == '(') 418 | { 419 | this->pop_operator(); 420 | } 421 | } 422 | else if (isOperator(text[i])) 423 | { 424 | while (!this->isEmpty_operator() && this->precedence(this->peek_operator()) >= this->precedence(text[i])) 425 | { 426 | this->apply_operation(); 427 | } 428 | this->push_operator(text[i]); 429 | } 430 | } 431 | 432 | while (!this->isEmpty_operator()) 433 | { 434 | this->apply_operation(); 435 | } 436 | 437 | this->pop(); 438 | } 439 | 440 | void Constant_folding::display() 441 | { 442 | std::cout << this->result << " / " << this->fresult < 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | bool Eagle::isAlphabetic(char c) 13 | { 14 | return ( (c >= 'a') && (c <= 'z') ) || ( (c >= 'A') && (c <= 'Z') ) || (c == '_'); 15 | } 16 | 17 | 18 | bool Eagle::isWord(char c) 19 | { 20 | return ( (c >= 'a') && (c <= 'z') ) || ( (c >= 'A') && (c <= 'Z') ) || ( (c >= '0') && (c <= '9') ) || (c == '_') || (c == '.'); 21 | } 22 | 23 | bool Eagle::isOperator(char c,char c2,int &i) 24 | { 25 | if( 26 | ( (c == '<') && (c2 == '<') ) || ( (c == '>') && (c2 == '>') ) || 27 | 28 | ( (c == '<') && (c2 == '=') ) || ( (c == '>') && (c2 == '=') ) || 29 | ( (c == '=') && (c2 == '=') ) || ( (c == '!') && (c2 == '=') ) || 30 | 31 | ( (c == '&') && (c2 == '!') ) || ( (c == '=') && (c2 == '?') ) || ( (c == '=') && (c2 == '+') ) || 32 | ( (c == '?') && (c2 == '=') ) || ( (c == '?') && (c2 == '!') ) || 33 | 34 | ( (c == '*') && (c2 == '=') ) || ( (c == '/') && (c2 == '=') ) || ( (c == '%') && (c2 == '=') ) || 35 | ( (c == '+') && (c2 == '=') ) || ( (c == '-') && (c2 == '=') ) || 36 | ( (c == '&') && (c2 == '=') ) || ( (c == '|') && (c2 == '=') ) || ( (c == '^') && (c2 == '=') ) 37 | ) 38 | { 39 | i++; 40 | return true; 41 | } 42 | 43 | return (c == '+') || (c == '-') || (c == '/') || (c == '*') || (c == '=') || (c == '&') || (c == '|') || (c == '^') || (c == '<') || (c == '>') || (c == '%'); 44 | } 45 | 46 | bool Eagle::isNumber(char c) 47 | { 48 | return ( (c >= '0') && (c <= '9') ); 49 | } 50 | 51 | 52 | int Eagle::isConstantFolding(char c1,int i,EAGLE_WORDS &tword) 53 | { 54 | if(c1 == '(') 55 | { 56 | tword.item.clear(); 57 | tword.type = TYPE_CONSTANT; 58 | 59 | tword.line = this->line; 60 | tword.col = this->col; 61 | EAGLE_DEFINE tdefine; 62 | std::string word; 63 | //tword.item += '('; 64 | 65 | i++; 66 | while(this->filetext[i] != 0) 67 | { 68 | char letter = this->filetext[i]; 69 | if(letter == ')') 70 | { 71 | if(word.size() != 0) 72 | { 73 | tdefine = this->define[word]; 74 | if(tdefine.exist == true) 75 | word = tdefine.text; 76 | 77 | 78 | if(tmacro.exist == true) 79 | { 80 | for(int l = 0;l < 8;l++) 81 | { 82 | if(this->kmacro[l] == word) 83 | { 84 | word = tmacro.arg[l]; 85 | l = 8; 86 | } 87 | } 88 | } 89 | 90 | } 91 | 92 | tword.item += word; 93 | return i; 94 | } 95 | else 96 | { 97 | 98 | if(isWord(letter)) 99 | { 100 | word += letter; 101 | 102 | } 103 | else 104 | { 105 | if(word.size() != 0) 106 | { 107 | tdefine = this->define[word]; 108 | if(tdefine.exist == true) 109 | word = tdefine.text; 110 | 111 | if(tmacro.exist == true) 112 | { 113 | for(int l = 0;l < 8;l++) 114 | { 115 | if(this->kmacro[l] == word) 116 | { 117 | word = tmacro.arg[l]; 118 | l = 8; 119 | } 120 | } 121 | } 122 | 123 | 124 | tword.item += word + letter; 125 | word = ""; 126 | }else 127 | tword.item += letter; 128 | } 129 | 130 | } 131 | 132 | i++; 133 | } 134 | } 135 | 136 | return i; 137 | } 138 | 139 | int Eagle::isText(char c1,int i,EAGLE_WORDS &tword) 140 | { 141 | if(c1 == '"') 142 | { 143 | tword.item.clear(); 144 | tword.type = TYPE_DATASTR; 145 | 146 | tword.line = this->line; 147 | tword.col = this->col; 148 | i++; 149 | while(this->filetext[i] != 0) 150 | { 151 | if(this->filetext[i] == '"') 152 | return i; 153 | else 154 | tword.item += this->filetext[i]; 155 | 156 | this->col++; 157 | if(this->filetext[i] == '\n') 158 | { 159 | this->line++; 160 | this->col = 0; 161 | } 162 | 163 | 164 | i++; 165 | } 166 | } 167 | 168 | return i; 169 | } 170 | 171 | int Eagle::isComment(char c1,char c2,int i) 172 | { 173 | 174 | if( (c1 == '/') && (c2 == '/') ) 175 | { 176 | while(this->filetext[i] != 0) 177 | { 178 | if(this->filetext[i] == '\n') 179 | { 180 | 181 | this->col = 0; 182 | return i; 183 | } 184 | 185 | 186 | i++; 187 | } 188 | } 189 | 190 | if( (c1 == '/') && (c2 == '*') ) 191 | { 192 | while(this->filetext[i] != 0) 193 | { 194 | if( (this->filetext[i] == '*') && (this->filetext[i+1] == '/') ) 195 | return i+2; 196 | 197 | this->col++; 198 | if(this->filetext[i] == '\n') 199 | { 200 | this->line++; 201 | this->col = 0; 202 | } 203 | 204 | i++; 205 | } 206 | } 207 | 208 | return i; 209 | } 210 | 211 | void Eagle::parser_word() 212 | { 213 | std::vector words; 214 | EAGLE_WORDS tword,tword2,ptword; 215 | tword2.type = TYPE_UNK; 216 | int scope = 0; 217 | 218 | std::string word = ""; 219 | 220 | bool label = false,endinst = true,bptr = false; 221 | 222 | int i = 0,iptr = 0; 223 | int preproc = 0; 224 | int parg = 0; 225 | std::string dword = ""; 226 | EAGLE_DEFINE tdefine,tdefine2; 227 | tdefine.exist = true; 228 | char token = 0; 229 | tmacro.exist = false; 230 | 231 | this->line = 1; 232 | this->col = 0; 233 | this->instructions.clear(); 234 | 235 | while(this->filetext[i] != 0) 236 | { 237 | 238 | i = isComment(this->filetext[i],this->filetext[i+1],i); 239 | 240 | if(preproc == -1) 241 | { 242 | label_macro: 243 | tmacro = tdefine; 244 | tmacro.exist = true; 245 | i-=1; 246 | this->filetext.insert(i,tdefine2.text); 247 | preproc = 6; 248 | } 249 | 250 | if(preproc == -1) 251 | { 252 | label_define: 253 | i-=1; 254 | this->filetext.insert(i,tdefine2.text); 255 | if(preproc != 6) 256 | preproc = 0; 257 | } 258 | 259 | if( (preproc == 0) || (preproc == 6) ) 260 | { 261 | i = isText(this->filetext[i],i,tword2); 262 | 263 | if(tword2.type == TYPE_DATASTR) 264 | { 265 | tword2.scope = scope; 266 | if(bptr == false) 267 | words.push_back(tword2); 268 | tword2.type = TYPE_UNK; 269 | } 270 | 271 | i = isConstantFolding(this->filetext[i],i,tword2); 272 | 273 | if(tword2.type == TYPE_CONSTANT) 274 | { 275 | tword2.scope = scope; 276 | if(bptr == false) 277 | words.push_back(tword2); 278 | tword2.type = TYPE_UNK; 279 | } 280 | } 281 | 282 | char letter = this->filetext[i]; 283 | char letter2 = this->filetext[i+1]; 284 | i++; 285 | 286 | //Define/Macro content 287 | if( (preproc == 2) || (preproc == 4)) 288 | tdefine.text += letter; 289 | 290 | if(isWord(letter)) 291 | { 292 | word += letter; 293 | } 294 | else 295 | { 296 | if(word.size() != 0) 297 | { 298 | 299 | //define/macro == word 300 | if(preproc == 6) 301 | { 302 | for(int l = 0;l < 8;l++) 303 | { 304 | if(this->kmacro[l] == word) 305 | { 306 | word = tdefine.arg[l]; 307 | l = 8; 308 | } 309 | } 310 | } 311 | 312 | if(preproc == 5) 313 | {/* 314 | if(token == '#') 315 | word = token + word; 316 | 317 | if(token == '$') 318 | word = token + word; 319 | 320 | if(token == '@') 321 | word = token + word; 322 | 323 | if(letter == ':') 324 | word += letter; 325 | */ 326 | tdefine.arg[parg] = word; 327 | 328 | parg++; 329 | parg &=7; 330 | } 331 | 332 | if( (preproc == 0) || (preproc == 6) ) 333 | { 334 | tdefine2 = this->define[word]; 335 | if(tdefine2.exist == true) 336 | { 337 | if(tdefine2.macro == false) 338 | { 339 | word = ""; 340 | goto label_define; 341 | }else 342 | { 343 | preproc = 5; 344 | parg = 0; 345 | } 346 | } 347 | } 348 | 349 | tword.item = word; 350 | if(isNumber(word[0])) 351 | { 352 | tword.type = TYPE_NUMBER; 353 | } 354 | else 355 | { 356 | tword.type = TYPE_WORD; 357 | 358 | 359 | if(letter == ':') 360 | { 361 | tword.type = TYPE_LABEL; 362 | label = true; 363 | } 364 | } 365 | 366 | if(preproc == 3) 367 | { 368 | dword = word; 369 | preproc = 4; 370 | tdefine.text = ""; 371 | tdefine.macro = true; 372 | } 373 | 374 | if(preproc == 1) 375 | { 376 | dword = word; 377 | preproc = 2; 378 | tdefine.text = ""; 379 | tdefine.macro = false; 380 | } 381 | //---- 382 | 383 | EAGLE_keywords tmp = this->keywords[word]; 384 | 385 | if(tmp == EAGLE_keywords::DEFINE) 386 | preproc = 1; 387 | 388 | if(tmp == EAGLE_keywords::MACRO) 389 | preproc = 3; 390 | 391 | if(tmp == EAGLE_keywords::END) 392 | { 393 | tword.type = TYPE_END; 394 | endinst = true; 395 | } 396 | 397 | if(bptr == true) 398 | { 399 | ptword.ptr[iptr] = word; 400 | ptword.ptype[iptr] = tword.type; 401 | ptword.ptoken1[iptr] = token; 402 | ptword.ptoken2[iptr] = letter; 403 | iptr++; 404 | iptr &= 3; 405 | ptword.pn = iptr; 406 | 407 | if( (tmp >= EAGLE_keywords::UINT8) && (tmp <= EAGLE_keywords::VOID)) 408 | ptword.ktype = tmp; 409 | 410 | } 411 | 412 | tword.line = this->line; 413 | tword.col = this->col-tword.item.size(); 414 | 415 | tword.scope = scope; 416 | tword.label = label; 417 | label = false; 418 | tword.token1 = token; 419 | tword.token2 = letter; 420 | 421 | if(tmp == EAGLE_keywords::ENDMACRO) 422 | { 423 | tmacro.exist = false; 424 | if(preproc == 4) 425 | { 426 | this->define[dword] = tdefine; 427 | preproc = 0; 428 | } 429 | 430 | if(preproc == 6) 431 | { 432 | preproc = 0; 433 | this->line--; 434 | } 435 | }else 436 | { 437 | if( (preproc == 0) || (preproc == 6) ) 438 | { 439 | if(bptr == false) 440 | words.push_back(tword); 441 | } 442 | 443 | } 444 | 445 | } 446 | 447 | token = letter; 448 | 449 | if( (preproc == 0) || (preproc == 6) ) 450 | if(this->isOperator(letter,letter2,i)) 451 | { 452 | word = letter; 453 | word += letter2; 454 | tword.item = word; 455 | tword.type = TYPE_OPERATOR; 456 | tword.line = this->line; 457 | tword.col = this->col-1; 458 | 459 | tword.scope = scope; 460 | if(bptr == false) 461 | words.push_back(tword); 462 | } 463 | 464 | if( (letter == ';') || ((letter == '\n') && (endinst == true)) ) 465 | { 466 | if(words.size() != 0) 467 | { 468 | this->instructions.push_back(words); 469 | words.clear(); 470 | } 471 | 472 | endinst = true; 473 | } 474 | 475 | if( (preproc == 0) || (preproc == 6) ) 476 | { 477 | if(letter == '[') 478 | { 479 | ptword.line = this->line; 480 | ptword.col = this->col; 481 | ptword.type = TYPE_PTR; 482 | ptword.scope = scope; 483 | ptword.label = false; 484 | iptr = 0; 485 | 486 | ptword.ptype[0] = TYPE_UNK; 487 | ptword.ptype[1] = TYPE_UNK; 488 | ptword.ptype[2] = TYPE_UNK; 489 | ptword.ptype[3] = TYPE_UNK; 490 | 491 | ptword.ktype = EAGLE_keywords::UINT8; 492 | ptword.pn = 0; 493 | 494 | bptr = true; 495 | } 496 | 497 | if(letter == ']') 498 | { 499 | ptword.item = ".ptr"; 500 | words.push_back(ptword); 501 | bptr = false; 502 | } 503 | } 504 | 505 | if( (preproc != 2) && (preproc != 4) ) 506 | { 507 | if(letter == '{') 508 | scope++; 509 | 510 | 511 | if(letter == '}') 512 | { 513 | scope--; 514 | if(scope >= 0) 515 | { 516 | if(words.size() != 0) 517 | { 518 | this->instructions.push_back(words); 519 | words.clear(); 520 | } 521 | 522 | tword.item = ".end"; 523 | tword.type = TYPE_END; 524 | tword.line = this->line; 525 | tword.col = this->col; 526 | 527 | tword.scope = scope; 528 | tword.label = label; 529 | words.push_back(tword); 530 | this->instructions.push_back(words); 531 | words.clear(); 532 | 533 | //endinst = false; 534 | endinst = true; 535 | }else 536 | { 537 | std::cout << "error line " << this->line << ": extra singleton }\n" ; 538 | this->error++; 539 | } 540 | } 541 | } 542 | 543 | 544 | 545 | 546 | word = ""; 547 | } 548 | 549 | 550 | this->col++; 551 | 552 | 553 | if(letter == '\n') 554 | { 555 | if(preproc == 5) 556 | { 557 | word = ""; 558 | goto label_macro; 559 | } 560 | 561 | if(preproc != 6) 562 | { 563 | this->line++; 564 | this->col = 0; 565 | } 566 | //define/macro declare 567 | if(preproc == 2) 568 | { 569 | tdefine.text.erase(tdefine.text.size() - 1); 570 | this->define[dword] = tdefine; 571 | preproc = 0; 572 | word = ""; 573 | } 574 | } 575 | 576 | 577 | 578 | } 579 | 580 | } 581 | 582 | -------------------------------------------------------------------------------- /src/Eagle_asm_z80.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | 12 | std::string Eagle::asm_z80_arg(const EAGLE_VARIABLE &src,int &type,std::string &labelp) 13 | { 14 | std::string srcvalue; 15 | 16 | type = 0; 17 | 18 | if(src.bimm == true) 19 | { 20 | srcvalue = std::to_string(src.immediate&0xFFFF); 21 | } 22 | else 23 | { 24 | if( (src.type >= EAGLE_keywords::ACC) && (src.type <= EAGLE_keywords::IDY) ) 25 | { 26 | type = 1; 27 | if(src.type == EAGLE_keywords::ACC) 28 | { 29 | srcvalue = "a"; 30 | } 31 | 32 | if(src.type == EAGLE_keywords::IDX) 33 | { 34 | srcvalue = "IX"; 35 | type = 2; 36 | } 37 | 38 | if(src.type == EAGLE_keywords::IDY) 39 | { 40 | srcvalue = "IY"; 41 | type = 2; 42 | } 43 | 44 | if(src.type == EAGLE_keywords::IDHL) 45 | { 46 | srcvalue = "hl"; 47 | type = 2; 48 | } 49 | 50 | if(src.type == EAGLE_keywords::IDH) 51 | { 52 | srcvalue = "h"; 53 | } 54 | 55 | if(src.type == EAGLE_keywords::IDL) 56 | { 57 | srcvalue = "l"; 58 | } 59 | 60 | if(src.type == EAGLE_keywords::REGDE) 61 | { 62 | type = 2; 63 | srcvalue = "de"; 64 | } 65 | 66 | if(src.type == EAGLE_keywords::REGBC) 67 | { 68 | type = 2; 69 | srcvalue = "bc"; 70 | } 71 | 72 | if( (src.type >= EAGLE_keywords::REG1) && (src.type <= EAGLE_keywords::REG4) ) 73 | { 74 | srcvalue = static_cast('b' + static_cast(src.type) - static_cast(EAGLE_keywords::REG1)); 75 | } 76 | } 77 | else 78 | { 79 | if(src.bptr == false) 80 | { 81 | if(src.blabel == true) 82 | { 83 | type = 0; 84 | srcvalue = labelp + ":"; 85 | } 86 | else 87 | { 88 | type = -1; 89 | srcvalue = "(" + std::to_string(src.address&0xFFFF) +")"; 90 | } 91 | }else 92 | { 93 | type = 1; 94 | if(src.ptr2.type == EAGLE_keywords::IDX) 95 | { 96 | srcvalue = "(IX," + std::to_string(src.ptr1.value) +")"; 97 | }else 98 | if(src.ptr2.type == EAGLE_keywords::IDY) 99 | { 100 | srcvalue = "(IY," + std::to_string(src.ptr1.value) +")"; 101 | } 102 | else 103 | if(src.ptr1.type == EAGLE_keywords::IDHL) 104 | { 105 | srcvalue = "(hl)"; 106 | } 107 | } 108 | } 109 | 110 | } 111 | 112 | return srcvalue; 113 | } 114 | 115 | 116 | void Eagle::asm_bru_z80(const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2,int type,int clabel) 117 | { 118 | std::string label_adr = ".label_b"+std::to_string(clabel); 119 | std::string flag = "NZ"; 120 | std::string src1value; 121 | std::string src2value; 122 | 123 | if(type == TYPE_IF) //if 124 | { 125 | label_adr = ".label_"+std::to_string(this->ilabel); 126 | this->ilabel++; 127 | } 128 | 129 | int type1,type2; 130 | int loopx = 0; 131 | 132 | src1value = this->asm_z80_arg(src1,type1,this->label1); 133 | src2value = this->asm_z80_arg(src2,type2,this->label2); 134 | 135 | if(type2 == 0) 136 | { 137 | if(src2.immediate == 0) 138 | { 139 | if(type1 == 1) 140 | { 141 | loopx = 1; 142 | if(src1.type == EAGLE_keywords::REG1) 143 | loopx = 2; 144 | } 145 | } 146 | } 147 | 148 | if(type == TYPE_IF) 149 | loopx = 0; 150 | 151 | if(type1 == 0) 152 | { 153 | if(src1.immediate == 1) 154 | { 155 | this->text_code += "jp " + label_adr + "\n"; 156 | return; 157 | } 158 | } 159 | 160 | if( (operator1 == '=') && (operator2 == '=') ) 161 | if(loopx != 0) 162 | { 163 | if(loopx == 2) 164 | { 165 | this->text_code += "djnz " + label_adr + "\n"; 166 | }else 167 | { 168 | this->text_code += "dec " + src1value + "\n"; 169 | this->text_code += "jp NZ," + label_adr + "\n"; 170 | } 171 | 172 | return; 173 | } 174 | 175 | if(src1.type != EAGLE_keywords::ACC) 176 | { 177 | this->text_code += "ld a," + src1value + "\n"; 178 | } 179 | 180 | if(type2 != -1) 181 | { 182 | if(operator1 == '&') 183 | { 184 | this->text_code += "and " + src2value + "\n"; 185 | flag = "NZ"; 186 | if(operator2 == '!') flag = "Z"; 187 | 188 | } 189 | else 190 | { 191 | this->text_code += "cp " + src2value + "\n"; 192 | } 193 | 194 | } 195 | else 196 | { 197 | this->text_code += "ld hl," + std::to_string(src2.address&0xFFFF) + "\n"; 198 | this->text_code += "cp (hl)\n"; 199 | } 200 | 201 | if( (operator1 == '=') && (operator2 == '=') ) 202 | flag = "NZ"; 203 | 204 | if( (operator1 == '!') && (operator2 == '=') ) 205 | flag = "Z"; 206 | 207 | if( (operator1 == '>') && (operator2 == '=') ) 208 | { 209 | flag = "C"; 210 | } 211 | else 212 | { 213 | if(operator1 == '>') 214 | { 215 | flag = "C"; 216 | this->text_code += "jp Z," + label_adr + "\n"; 217 | this->text_code += "cp " + src2value + "\n"; 218 | } 219 | 220 | } 221 | 222 | bool jflag = false; 223 | if( (operator1 == '<') && (operator2 == '=') ) 224 | { 225 | flag = "NC"; 226 | this->text_code += "jp Z,.label_a" + std::to_string(this->ilabel) + "\n"; 227 | this->text_code += "cp " + src2value + "\n"; 228 | jflag = true; 229 | } 230 | else 231 | { 232 | if(operator1 == '<') 233 | flag = "NC"; 234 | } 235 | 236 | if(type != TYPE_IF) 237 | { 238 | if(flag == "NZ") flag = "Z"; 239 | else 240 | if(flag == "NC") flag = "C"; 241 | else 242 | if(flag == "Z") flag = "NZ"; 243 | else 244 | if(flag == "C") flag = "NC"; 245 | 246 | } 247 | 248 | this->text_code += "jp " + flag + "," + label_adr + "\n"; 249 | 250 | 251 | if(jflag == true) 252 | this->text_code += ".label_a"+std::to_string(this->ilabel)+":\n"; 253 | } 254 | 255 | void Eagle::asm_call_jump_z80(const EAGLE_VARIABLE &src,int ninst,int type) 256 | { 257 | std::string src1value = this->labelcall; 258 | std::string mnemonic = "jp ",reg = "a"; 259 | if(type >= 1) 260 | mnemonic = "call "; 261 | 262 | for(int i = 0;i < ninst;i++) 263 | { 264 | EAGLE_VARIABLE var = this->arg[i]; 265 | 266 | if(var.type == EAGLE_keywords::IDX) 267 | { 268 | reg = "IX"; 269 | }else 270 | if(var.type == EAGLE_keywords::IDY) 271 | { 272 | reg = "IY"; 273 | }else 274 | if(var.type == EAGLE_keywords::ACC) 275 | { 276 | reg = "IX"; 277 | } 278 | else 279 | if(var.type == EAGLE_keywords::REGBC) 280 | { 281 | reg = "bc"; 282 | } 283 | else 284 | if(var.type == EAGLE_keywords::REGDE) 285 | { 286 | reg = "de"; 287 | } 288 | else 289 | if(var.type == EAGLE_keywords::IDHL) 290 | { 291 | reg = "hl"; 292 | } 293 | else 294 | if(var.type == EAGLE_keywords::REG2) 295 | { 296 | this->text_code += "ld a,b\n"; 297 | } 298 | else 299 | if(var.type == EAGLE_keywords::REG3) 300 | { 301 | this->text_code += "ld a,c\n"; 302 | } 303 | else 304 | if(var.type == EAGLE_keywords::REG4) 305 | { 306 | this->text_code += "ld a,d\n"; 307 | } 308 | else 309 | if(var.type == EAGLE_keywords::REG5) 310 | { 311 | this->text_code += "ld a,e\n"; 312 | } 313 | else 314 | if(var.type == EAGLE_keywords::IDH) 315 | { 316 | this->text_code += "ld a,h\n"; 317 | } 318 | else 319 | if(var.type == EAGLE_keywords::IDL) 320 | { 321 | this->text_code += "ld a,l\n"; 322 | } 323 | else 324 | { 325 | 326 | 327 | if( (var.type == EAGLE_keywords::UINT8) || (var.type == EAGLE_keywords::INT8)) 328 | { 329 | this->text_code += "ld a,(" + std::to_string(var.address&0xFFFF) + ")\n"; 330 | } 331 | else 332 | if( (var.type == EAGLE_keywords::UINT16) || (var.type == EAGLE_keywords::INT16)) 333 | { 334 | this->text_code += "ld de,(" + std::to_string(var.address&0xFFFF) + ")\n"; 335 | reg = "de"; 336 | } 337 | else 338 | if(var.bimm == true) 339 | { 340 | if(var.immediate < 0x100) 341 | { 342 | this->text_code += "ld a," + std::to_string(var.immediate&0xFFFF) + "\n"; 343 | }else 344 | { 345 | this->text_code += "ld de," + std::to_string(var.immediate&0xFFFF) + "\n"; 346 | reg = "de"; 347 | } 348 | 349 | } 350 | else 351 | 352 | if(var.bimm == true) 353 | { 354 | this->text_code += "ld de," + std::to_string(var.immediate&0xFFFF) + "\n"; 355 | reg = "de"; 356 | } 357 | else 358 | if(var.blabel == true) 359 | { 360 | this->text_code += "ld de," + this->labelarg[i] + "\n"; 361 | reg = "de"; 362 | } 363 | } 364 | 365 | this->text_code += "ld (" + src1value + "..arg" + std::to_string(i) +"@)," + reg +"\n"; 366 | } 367 | 368 | //------ 369 | if(src.bimm == true) 370 | { 371 | src1value = std::to_string(src.immediate); 372 | }else 373 | { 374 | if(src.blabel == false) 375 | { 376 | if(src.type == EAGLE_keywords::UINT16) 377 | { 378 | this->text_code += "ld hl," + std::to_string(src.address) +"\n"; 379 | src1value = "(hl)"; 380 | } 381 | 382 | if(src.type == EAGLE_keywords::IDX) 383 | { 384 | src1value = "(IX)"; 385 | } 386 | if(src.type == EAGLE_keywords::IDY) 387 | { 388 | src1value = "(IY)"; 389 | } 390 | } 391 | } 392 | 393 | this->text_code += mnemonic + src1value +"\n"; 394 | } 395 | 396 | void Eagle::asm_return_z80(const EAGLE_VARIABLE &ret,bool retvoid) 397 | { 398 | if(retvoid == true) 399 | { 400 | this->text_code += "ret\n"; 401 | 402 | }else 403 | { 404 | if(ret.type == EAGLE_keywords::IDX) 405 | { 406 | this->text_code += "ld a,IX\n"; 407 | } 408 | 409 | if(ret.type == EAGLE_keywords::IDY) 410 | { 411 | this->text_code += "ld a,IY\n"; 412 | } 413 | 414 | if(ret.type != EAGLE_keywords::ACC) 415 | { 416 | if(ret.bimm == true) 417 | this->text_code += "ld a,"+ std::to_string(ret.immediate&0xFF) +"\n"; 418 | else 419 | this->text_code += "ld a,("+ std::to_string(ret.address) +")\n"; 420 | } 421 | 422 | this->text_code += "ret\n"; 423 | } 424 | } 425 | 426 | void Eagle::asm_alu_z80(const EAGLE_VARIABLE &dst,const EAGLE_VARIABLE &src1,const EAGLE_VARIABLE &src2,const char operator1,const char operator2) 427 | { 428 | std::string mnemonic; 429 | std::string src1value,dstvalue; 430 | std::string src2value; 431 | std::string reg = "c",rega = ""; 432 | 433 | int typed,type1,type2; 434 | 435 | dstvalue = this->asm_z80_arg(dst,typed,this->label1); 436 | src1value = this->asm_z80_arg(src1,type1,this->label1); 437 | src2value = this->asm_z80_arg(src2,type2,this->label2); 438 | 439 | 440 | if(operator1 == '=') 441 | { 442 | //16 bits 443 | if(dst.type == EAGLE_keywords::UINT16) 444 | { 445 | if( (typed <= 0) && (type2 <= 0) ) 446 | { 447 | this->text_code += "ld de," + src2value + "\n"; 448 | this->text_code += "ld " + dstvalue + ",de\n"; 449 | 450 | return; 451 | } 452 | 453 | if( (typed < 0) && (type2 == 2) ) 454 | { 455 | this->text_code += "ld de," + src2value + "\n"; 456 | this->text_code += "ld " + dstvalue + ",de\n"; 457 | 458 | return; 459 | } 460 | 461 | if(type2 == 2) 462 | { 463 | this->text_code += "ld " + dstvalue + "," + src2value + "\n"; 464 | return; 465 | } 466 | 467 | } 468 | 469 | if( (typed == 1) && (type2 == 0) && (src2.immediate == 0) ) 470 | { 471 | this->text_code += "xor " + dstvalue +" \n"; 472 | return; 473 | } 474 | 475 | if( (typed > 0) && (type2 >= 0) ) 476 | { 477 | this->text_code += "ld " + dstvalue + "," + src2value +" \n"; 478 | return; 479 | } 480 | 481 | 482 | 483 | 484 | if(typed == 2) 485 | { 486 | this->text_code += "ld " + dstvalue + "," + src2value +" \n"; 487 | return; 488 | } 489 | 490 | if( (type2 == 0) && (src2.immediate == 0) ) 491 | { 492 | this->text_code += "xor a\n"; 493 | } 494 | else 495 | if(src2.type != EAGLE_keywords::ACC) 496 | this->text_code += "ld a," + src2value + "\n"; 497 | 498 | if(dst.type != EAGLE_keywords::ACC) 499 | this->text_code += "ld " + dstvalue + ",a\n"; 500 | return; 501 | } 502 | 503 | if(operator1 == '+') 504 | { 505 | mnemonic = "add "; 506 | rega = "a,"; 507 | 508 | 509 | if( (dst.type != EAGLE_keywords::UINT16) && (src1.type == dst.type) && (type2 == 0) && ( (src2.immediate == 1) || (src2.immediate == 2) ) ) 510 | { 511 | if(type1 > 0) 512 | { 513 | this->text_code += "inc " + dstvalue + "\n"; 514 | 515 | if(src2.immediate == 2) 516 | this->text_code += "inc " + dstvalue + "\n"; 517 | 518 | return; 519 | } 520 | 521 | 522 | if(type1 == -1) 523 | { 524 | this->text_code += "ld hl," + std::to_string(src1.address&0xFFFF) + "\n"; 525 | this->text_code += "inc (hl)\n"; 526 | 527 | if(src2.immediate == 2) 528 | this->text_code += "inc (hl)\n"; 529 | return; 530 | } 531 | } 532 | } 533 | 534 | 535 | if(operator1 == '-') 536 | { 537 | mnemonic = "sub "; 538 | if( (dst.type != EAGLE_keywords::UINT16) && (src1.type == dst.type) && (type2 == 0) && ( (src2.immediate == 1) || (src2.immediate == 2) ) ) 539 | { 540 | if(type1 > 0) 541 | { 542 | this->text_code += "dec " + dstvalue + "\n"; 543 | if(src2.immediate == 2) 544 | this->text_code += "dec " + dstvalue + "\n"; 545 | 546 | return; 547 | } 548 | 549 | 550 | if(type1 == -1) 551 | { 552 | this->text_code += "ld hl," + std::to_string(src1.address&0xFFFF) + "\n"; 553 | this->text_code += "dec (hl)\n"; 554 | 555 | if(src2.immediate == 2) 556 | this->text_code += "dec (hl)\n"; 557 | 558 | return; 559 | } 560 | } 561 | } 562 | 563 | int op_spe = 0; 564 | 565 | 566 | if(operator1 == '&') 567 | mnemonic = "and "; 568 | 569 | if(operator1 == '|') 570 | mnemonic = "or "; 571 | 572 | if(operator1 == '^') 573 | mnemonic = "xor "; 574 | 575 | 576 | int shift = 0; 577 | 578 | if(operator1 == '<') 579 | { 580 | op_spe = 1; 581 | mnemonic = "sla "; 582 | shift = 1; 583 | } 584 | 585 | 586 | if(operator1 == '>') 587 | { 588 | op_spe = 1; 589 | mnemonic = "srl "; 590 | shift = 1; 591 | } 592 | 593 | 594 | 595 | if(operator1 == '*') 596 | { 597 | op_spe = 2; 598 | } 599 | 600 | if(operator1 == '/') 601 | { 602 | op_spe = 3; 603 | } 604 | 605 | //---- 606 | 607 | bool hlopti = false; 608 | 609 | 610 | if( (dst.type == EAGLE_keywords::UINT16) && (src1.type == EAGLE_keywords::UINT16) ) 611 | { 612 | if( (src2.type == EAGLE_keywords::UINT16) || (type2 == 0) ) 613 | { 614 | this->text_code += "ld hl," + src1value + "\n"; 615 | this->text_code += "ld de," + src2value + "\n"; 616 | 617 | 618 | if(operator1 == '+') 619 | this->text_code += "add hl,de\n"; 620 | else 621 | if(operator1 == '-') 622 | { 623 | this->text_code += "or a\n"; 624 | this->text_code += "sbc hl,de\n"; 625 | 626 | }else 627 | { 628 | this->text_code += "ld a,l\n"; 629 | this->text_code += mnemonic + "d\n"; 630 | this->text_code += "ld l,a\n"; 631 | 632 | this->text_code += "ld a,h\n"; 633 | this->text_code += mnemonic + "e\n"; 634 | this->text_code += "ld h,a\n"; 635 | } 636 | 637 | 638 | this->text_code += "ld " + dstvalue + ",hl\n"; 639 | 640 | return; 641 | } 642 | } 643 | 644 | if(type1 == -1) 645 | { 646 | if(dstvalue == src1value) 647 | { 648 | dstvalue = "(hl)"; 649 | src1value = "(hl)"; 650 | this->text_code += "ld hl," + std::to_string(src1.address&0xFFFF) + "\n"; 651 | 652 | hlopti = true; 653 | } 654 | } 655 | 656 | if( (type2 == 1) || (type2 == 0) ) 657 | { 658 | reg = src2value; 659 | } 660 | else 661 | if(type2 == -1) 662 | { 663 | if(hlopti == false) 664 | { 665 | this->text_code += "ld hl," + std::to_string(src2.address&0xFFFF) + "\n"; 666 | reg = "(hl)"; 667 | 668 | if(dstvalue == src2value) 669 | dstvalue = "(hl)"; 670 | 671 | }else 672 | { 673 | this->text_code += "ld a," + src2value + "\n"; 674 | this->text_code += "ld c,a\n"; 675 | } 676 | 677 | } 678 | else 679 | { 680 | 681 | } 682 | 683 | if(dstvalue == src1value) 684 | shift += 1; 685 | 686 | if(type1 != 2) 687 | { 688 | if(src1.type != EAGLE_keywords::ACC) 689 | { 690 | if(shift != 2) 691 | this->text_code += "ld a," + src1value + "\n"; 692 | } 693 | }else 694 | { 695 | this->text_code += "ld de," + src2value + "\n"; 696 | reg = ",de"; 697 | rega = src1value; 698 | } 699 | 700 | if(op_spe == 0) 701 | this->text_code += mnemonic + rega + reg +"\n"; 702 | 703 | if(op_spe == 1) 704 | { 705 | if(type2 == 0) 706 | { 707 | for(int i = 0; i < (src2.immediate&7);i++) 708 | this->text_code += mnemonic + src1value +"\n"; 709 | 710 | 711 | if(dstvalue == src1value) 712 | return; 713 | }else 714 | { 715 | if(operator1 == '>') 716 | this->text_code += "call higueul_std_sla\n"; 717 | else 718 | this->text_code += "call higueul_std_srl\n"; 719 | } 720 | } 721 | 722 | if(op_spe == 2) 723 | { 724 | this->text_code += "call higueul_std_mul\n"; 725 | } 726 | 727 | if(op_spe == 3) 728 | { 729 | this->text_code += "call higueul_std_div\n"; 730 | } 731 | 732 | if(typed != 2) 733 | { 734 | if(dst.type != EAGLE_keywords::ACC) 735 | this->text_code += "ld " + dstvalue + ",a\n"; 736 | } 737 | else 738 | { 739 | if(dst.type != src1.type) 740 | this->text_code += "ld " + dstvalue + ",de\n"; 741 | } 742 | 743 | 744 | 745 | 746 | } 747 | -------------------------------------------------------------------------------- /src/Eagle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "Eagle.hpp" 11 | #include "CPU_Z80.hpp" 12 | 13 | 14 | 15 | Eagle::Eagle() 16 | { 17 | this->keywords["int8"] = EAGLE_keywords::INT8; 18 | this->keywords["int16"] = EAGLE_keywords::INT16; 19 | this->keywords["int32"] = EAGLE_keywords::INT32; 20 | this->keywords["int64"] = EAGLE_keywords::INT64; 21 | 22 | this->keywords["uint8"] = EAGLE_keywords::UINT8; 23 | this->keywords["uint16"] = EAGLE_keywords::UINT16; 24 | this->keywords["uint32"] = EAGLE_keywords::UINT32; 25 | this->keywords["uint64"] = EAGLE_keywords::UINT64; 26 | 27 | this->keywords["float16"] = EAGLE_keywords::FLOAT16; 28 | this->keywords["float32"] = EAGLE_keywords::FLOAT32; 29 | this->keywords["float64"] = EAGLE_keywords::FLOAT64; 30 | 31 | //this->keywords["vfloat"] = EAGLE_keywords::VFLOAT; 32 | //this->keywords["vint"] = EAGLE_keywords::VINT; 33 | 34 | this->keywords["void"] = EAGLE_keywords::VOID; 35 | 36 | this->keywords["register"] = EAGLE_keywords::REGISTER; 37 | this->keywords["spm"] = EAGLE_keywords::SPM; 38 | this->keywords["lib"] = EAGLE_keywords::LIB; 39 | this->keywords["stack"] = EAGLE_keywords::STACK; 40 | 41 | this->keywords["if"] = EAGLE_keywords::IF; 42 | this->keywords["else"] = EAGLE_keywords::ELSE; 43 | this->keywords["do"] = EAGLE_keywords::DO; 44 | this->keywords["while"] = EAGLE_keywords::WHILE; 45 | this->keywords["jump"] = EAGLE_keywords::JUMP; 46 | this->keywords["call"] = EAGLE_keywords::CALL; 47 | this->keywords["return"] = EAGLE_keywords::RETURN; 48 | this->keywords["loop"] = EAGLE_keywords::LOOP; 49 | 50 | this->keywords["func"] = EAGLE_keywords::FUNC; 51 | this->keywords["funcspm"] = EAGLE_keywords::FUNCSPM; 52 | this->keywords["funclib"] = EAGLE_keywords::FUNCLIB; 53 | this->keywords["proc"] = EAGLE_keywords::PROC; 54 | this->keywords[".end"] = EAGLE_keywords::END; 55 | 56 | this->keywords["asm"] = EAGLE_keywords::ASM; 57 | 58 | this->keywords[".define"] = EAGLE_keywords::DEFINE; 59 | this->keywords[".incbin"] = EAGLE_keywords::INCBIN; 60 | this->keywords[".code"] = EAGLE_keywords::CODE; 61 | this->keywords[".rodata"] = EAGLE_keywords::RODATA; 62 | this->keywords[".bss"] = EAGLE_keywords::BSS; 63 | this->keywords[".map.func"] = EAGLE_keywords::FUNCMAP; 64 | this->keywords[".map.funcspm"] = EAGLE_keywords::FUNCMAPSPM; 65 | this->keywords[".map.funclib"] = EAGLE_keywords::FUNCMAPLIB; 66 | this->keywords[".map.spm"] = EAGLE_keywords::SPMMAP; 67 | this->keywords[".map.lib"] = EAGLE_keywords::LIBMAP; 68 | this->keywords[".endmacro"] = EAGLE_keywords::ENDMACRO; 69 | this->keywords[".org"] = EAGLE_keywords::ORG; 70 | 71 | this->keywords[".macro"] = EAGLE_keywords::MACRO; 72 | 73 | 74 | this->keywords[".data.b"] = EAGLE_keywords::DATAB; 75 | this->keywords[".data.w"] = EAGLE_keywords::DATAW; 76 | this->keywords[".data.l"] = EAGLE_keywords::DATAL; 77 | this->keywords[".data.q"] = EAGLE_keywords::DATAQ; 78 | this->keywords[".data.s"] = EAGLE_keywords::DATAS; 79 | this->keywords[".data.h"] = EAGLE_keywords::DATAH; 80 | this->keywords[".data.f"] = EAGLE_keywords::DATAF; 81 | this->keywords[".data.d"] = EAGLE_keywords::DATAD; 82 | 83 | 84 | this->filetext.reserve(0x200000); 85 | this->text_code.reserve(0x200000); 86 | this->mnemonic.reserve(0x100); 87 | this->filebin.reserve(0x800000); 88 | 89 | this->col = 0; 90 | this->line = 1; 91 | this->error = 0; 92 | this->ilabel = 0; 93 | this->mode_alloc = ALLOC_WRAM; 94 | 95 | this->wram_address = 0; 96 | 97 | this->lib_address = 0; 98 | this->spm_address = 0; 99 | this->funcspm_address = 0; 100 | this->funclib_address = 0; 101 | 102 | this->lib_init = 0; 103 | this->spm_init = 0; 104 | this->funcspm_init = 0; 105 | this->funclib_init = 0; 106 | 107 | this->register_address = 0; 108 | this->stack_address = 0; 109 | this->idf = 0; 110 | this->sizebin = 0; 111 | this->mmap = 0; 112 | this->snesromfree = 0; 113 | 114 | this->target = TARGET_65816; 115 | 116 | //6502 117 | this->gvariable["acc"].type = EAGLE_keywords::ACC; 118 | this->gvariable["idx"].type = EAGLE_keywords::IDX; 119 | this->gvariable["idy"].type = EAGLE_keywords::IDY; 120 | 121 | this->gvariable["reg1"].type = EAGLE_keywords::REG1; //B / BX 122 | this->gvariable["reg2"].type = EAGLE_keywords::REG2; //C / CX 123 | this->gvariable["reg3"].type = EAGLE_keywords::REG3; //D / DX 124 | this->gvariable["reg4"].type = EAGLE_keywords::REG4; //E / BP 125 | this->gvariable["reg5"].type = EAGLE_keywords::REG5; //F / SI 126 | this->gvariable["reg6"].type = EAGLE_keywords::REG6; //0 / DI 127 | 128 | this->gvariable["regsp"].type = EAGLE_keywords::REGSP; //SP 129 | 130 | //Z80 131 | this->gvariable["idh"].type = EAGLE_keywords::IDH; 132 | this->gvariable["idl"].type = EAGLE_keywords::IDL; 133 | 134 | this->gvariable["rbc"].type = EAGLE_keywords::REGBC; 135 | this->gvariable["rde"].type = EAGLE_keywords::REGDE; 136 | 137 | this->gvariable["idhl"].type = EAGLE_keywords::IDHL; 138 | 139 | this->kmacro[0] = ".arg1"; 140 | this->kmacro[1] = ".arg2"; 141 | this->kmacro[2] = ".arg3"; 142 | this->kmacro[3] = ".arg4"; 143 | 144 | this->kmacro[4] = ".arg5"; 145 | this->kmacro[5] = ".arg6"; 146 | this->kmacro[6] = ".arg7"; 147 | this->kmacro[7] = ".arg8"; 148 | 149 | 150 | this->debug = false; 151 | this->bout_asm = false; 152 | this->bcycle = false; 153 | this->bmesen = false; 154 | this->snes_checksum = false; 155 | } 156 | 157 | uint64_t Eagle::alloc(EAGLE_keywords type,int n) 158 | { 159 | int value; 160 | switch(type) 161 | { 162 | case EAGLE_keywords::UINT8: 163 | value = n; 164 | break; 165 | 166 | case EAGLE_keywords::UINT16: 167 | value = 2*n; 168 | break; 169 | 170 | case EAGLE_keywords::UINT32: 171 | value = 4*n; 172 | break; 173 | 174 | case EAGLE_keywords::UINT64: 175 | value = 8*n; 176 | break; 177 | 178 | case EAGLE_keywords::INT8: 179 | value = n; 180 | break; 181 | 182 | case EAGLE_keywords::INT16: 183 | value = 2*n; 184 | break; 185 | 186 | case EAGLE_keywords::INT32: 187 | value = 4*n; 188 | break; 189 | 190 | case EAGLE_keywords::INT64: 191 | value = 8*n; 192 | break; 193 | 194 | case EAGLE_keywords::FLOAT16: 195 | value = 2*n; 196 | break; 197 | 198 | case EAGLE_keywords::FLOAT32: 199 | value = 4*n; 200 | break; 201 | 202 | case EAGLE_keywords::FLOAT64: 203 | value = 8*n; 204 | break; 205 | 206 | default: 207 | 208 | return 0; 209 | break; 210 | 211 | } 212 | 213 | this->varsize = value; 214 | 215 | uint64_t tmp = 0; 216 | 217 | if(this->mode_alloc == ALLOC_FRAM) 218 | { 219 | tmp = this->func_address; 220 | this->func_address += value; 221 | } 222 | 223 | if(this->mode_alloc == ALLOC_WRAM) 224 | { 225 | tmp = this->wram_address; 226 | this->wram_address += value; 227 | } 228 | 229 | if(this->mode_alloc == ALLOC_SPM) 230 | { 231 | tmp = this->spm_address; 232 | this->spm_address += value; 233 | } 234 | 235 | if(this->mode_alloc == ALLOC_LIB) 236 | { 237 | tmp = this->lib_address; 238 | this->lib_address += value; 239 | } 240 | 241 | if(this->mode_alloc == ALLOC_FSPM) 242 | { 243 | tmp = this->funcspm_address; 244 | this->funcspm_address += value; 245 | } 246 | 247 | if(this->mode_alloc == ALLOC_FLIB) 248 | { 249 | tmp = this->funclib_address; 250 | this->funclib_address += value; 251 | } 252 | 253 | if(this->mode_alloc == ALLOC_REGISTER) 254 | { 255 | tmp = this->register_address; 256 | this->register_address += 1; 257 | } 258 | 259 | if(this->mode_alloc == ALLOC_STACK) 260 | { 261 | tmp = this->stack_address; 262 | this->stack_address += value; 263 | } 264 | 265 | 266 | return tmp; 267 | } 268 | 269 | void Eagle::write_file(const char *path,std::string text) 270 | { 271 | std::ofstream file(path, std::ios::binary); 272 | 273 | if(!file.is_open()) 274 | { 275 | std::cerr << "Error: Unable to open file " << path << std::endl; 276 | exit(1); 277 | return; 278 | } 279 | 280 | file.write(text.c_str(), text.size()); 281 | 282 | file.close(); 283 | } 284 | 285 | void Eagle::write_file_bin(const char *path) 286 | { 287 | std::ofstream file(path, std::ios::binary); 288 | 289 | if(!file.is_open()) 290 | { 291 | std::cerr << "Error: Unable to open file " << path << std::endl; 292 | exit(1); 293 | return; 294 | } 295 | 296 | file.write(this->filebin.data(), this->filebin.size()); 297 | 298 | file.close(); 299 | } 300 | 301 | void Eagle::load_file(const char *path) 302 | { 303 | std::ifstream file(path, std::ios::binary); 304 | 305 | if(!file.is_open()) 306 | { 307 | std::cerr << "Error: Unable to open file " << path << std::endl; 308 | exit(1); 309 | return; 310 | } 311 | 312 | std::cerr << "File: "<< path << "\n"; 313 | 314 | file.seekg(0, std::ios::end); 315 | std::streampos filesizesp = file.tellg(); 316 | int filesize = static_cast(filesizesp); 317 | 318 | file.seekg(0, std::ios::beg); 319 | 320 | this->filetext.resize(filesize+5); 321 | 322 | file.read(&this->filetext[0], filesize); 323 | this->filetext[filesize+0] = 0; 324 | this->filetext[filesize+1] = 0; 325 | this->filetext[filesize+2] = 0; 326 | this->filetext[filesize+3] = 0; 327 | 328 | file.close(); 329 | } 330 | 331 | void Eagle::load_file_bin(const char *path,std::vector &data) 332 | { 333 | std::ifstream file(path, std::ios::binary); 334 | 335 | if(!file.is_open()) 336 | { 337 | std::cerr << "Error: Unable to open file " << path << std::endl; 338 | exit(1); 339 | return; 340 | } 341 | 342 | file.seekg(0, std::ios::end); 343 | std::streampos filesizesp = file.tellg(); 344 | int filesize = static_cast(filesizesp); 345 | 346 | file.seekg(0, std::ios::beg); 347 | 348 | data.resize(filesize); 349 | file.read(data.data(), filesize); 350 | 351 | file.close(); 352 | } 353 | 354 | 355 | bool Eagle::isOperator_move(char c,char c2) 356 | { 357 | return (c == '=') || 358 | ( (c == '+') && (c2 == '=') ) || ( (c == '-') && (c2 == '=') ) || ( (c == '=') && (c2 == '?') ) || ( (c == '=') && (c2 == '+') ) || 359 | ( (c == '*') && (c2 == '=') ) || ( (c == '/') && (c2 == '=') ) || ( (c == '%') && (c2 == '=') ) || 360 | ( (c == '&') && (c2 == '=') ) || ( (c == '|') && (c2 == '=') ) || ( (c == '^') && (c2 == '=') ); 361 | } 362 | 363 | bool Eagle::isOperator_cmp(char c,char c2) 364 | { 365 | return (c == '<') || (c == '>') || (c == '&') || 366 | ( (c == '<') && (c2 == '=') ) || ( (c == '>') && (c2 == '=') ) || 367 | ( (c == '=') && (c2 == '=') ) || ( (c == '!') && (c2 == '=') ) || 368 | ( (c == '?') && (c2 == '=') ) || ( (c == '?') && (c2 == '!') ) || 369 | ( (c == '&') && (c2 == '!') ) 370 | ; 371 | } 372 | 373 | bool Eagle::isOperator_calcul(char c,char c2) 374 | { 375 | return (c == '+') || (c == '-') || (c == '/') || (c == '*') || (c == '%') || 376 | (c == '&') || (c == '|') || (c == '^') || ( (c == '<') && (c2 == '<') ) || ( (c == '>') && (c2 == '>') ); 377 | } 378 | 379 | int Eagle::line_code_asm(int mode) 380 | { 381 | std::string word; 382 | char letter; 383 | mnemonic.clear(); 384 | bool comment = false; 385 | bool path = false; 386 | static uint64_t moffset; 387 | static std::string mstr; 388 | 389 | EAGLE_MNEMONIQUE tmnemonic; 390 | 391 | while(this->text_code[idf] != 0) 392 | { 393 | letter = this->text_code[idf]; 394 | idf++; 395 | 396 | if(letter == ';') 397 | comment = true; 398 | 399 | 400 | if(path == true) 401 | { 402 | if(letter != '\n') 403 | word += letter; 404 | }else 405 | if(comment == false) 406 | { 407 | if(isWord(letter)) 408 | { 409 | word += letter; 410 | } 411 | else 412 | { 413 | if(word.size() != 0) 414 | { 415 | tmnemonic.token2 = letter; 416 | 417 | if(isNumber(word[0])) 418 | { 419 | tmnemonic.value = std::stoll(word); 420 | tmnemonic.type = 0; 421 | } 422 | else 423 | tmnemonic.type = 1; 424 | 425 | if(tmnemonic.token1 == '$') 426 | { 427 | tmnemonic.value = std::stoll(word, nullptr, 16); 428 | tmnemonic.type = 0; 429 | } 430 | 431 | tmnemonic.item = word; 432 | 433 | 434 | if(word == ".incbin") 435 | path = true; 436 | 437 | mnemonic.push_back(tmnemonic); 438 | word = ""; 439 | } 440 | if(idf-2 > 0) 441 | tmnemonic.token0 = this->text_code[idf-2]; 442 | tmnemonic.token1 = letter; 443 | } 444 | } 445 | 446 | 447 | if(letter == '\n') 448 | { 449 | bool keyl = false; 450 | comment = false; 451 | path = false; 452 | 453 | if(mnemonic.size() > 0) 454 | { 455 | int n = mnemonic.size(); 456 | if(mnemonic[0].item == ".db") 457 | { 458 | if(mode == 1) 459 | { 460 | for(int i = 1;i < n;i++) 461 | { 462 | if(mnemonic[i].type == 0) 463 | { 464 | this->filebin.push_back(mnemonic[i].value); 465 | }else 466 | { 467 | this->filebin.push_back(this->labelbin[mnemonic[i].item]); 468 | } 469 | } 470 | } 471 | this->offset += mnemonic.size()-1; 472 | mnemonic.clear(); 473 | keyl = true; 474 | } 475 | 476 | if(mnemonic[0].item == ".dw") 477 | { 478 | if(mode == 1) 479 | { 480 | for(int i = 1;i < n;i++) 481 | { 482 | if(mnemonic[i].type == 0) 483 | { 484 | this->filebin.push_back(mnemonic[i].value); 485 | this->filebin.push_back(mnemonic[i].value>>8); 486 | }else 487 | { 488 | this->filebin.push_back(this->labelbin[mnemonic[i].item]); 489 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>8); 490 | } 491 | } 492 | 493 | } 494 | this->offset += (mnemonic.size()-1)*2; 495 | mnemonic.clear(); 496 | keyl = true; 497 | } 498 | 499 | if(mnemonic[0].item == ".dd") 500 | { 501 | if(mode == 1) 502 | { 503 | for(int i = 1;i < n;i++) 504 | { 505 | if(mnemonic[i].type == 0) 506 | { 507 | this->filebin.push_back(mnemonic[i].value); 508 | this->filebin.push_back(mnemonic[i].value>>8); 509 | this->filebin.push_back(mnemonic[i].value>>16); 510 | this->filebin.push_back(mnemonic[i].value>>24); 511 | }else 512 | { 513 | this->filebin.push_back(this->labelbin[mnemonic[i].item]); 514 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>8); 515 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>16); 516 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>24); 517 | } 518 | } 519 | 520 | } 521 | this->offset += (mnemonic.size()-1)*4; 522 | mnemonic.clear(); 523 | keyl = true; 524 | } 525 | 526 | if(mnemonic[0].item == ".dq") 527 | { 528 | if(mode == 1) 529 | { 530 | for(int i = 1;i < n;i++) 531 | { 532 | if(mnemonic[i].type == 0) 533 | { 534 | this->filebin.push_back(mnemonic[i].value); 535 | this->filebin.push_back(mnemonic[i].value>>8); 536 | this->filebin.push_back(mnemonic[i].value>>16); 537 | this->filebin.push_back(mnemonic[i].value>>24); 538 | 539 | this->filebin.push_back(mnemonic[i].value>>32); 540 | this->filebin.push_back(mnemonic[i].value>>40); 541 | this->filebin.push_back(mnemonic[i].value>>48); 542 | this->filebin.push_back(mnemonic[i].value>>56); 543 | }else 544 | { 545 | this->filebin.push_back(this->labelbin[mnemonic[i].item]); 546 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>8); 547 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>16); 548 | this->filebin.push_back(this->labelbin[mnemonic[i].item]>>24); 549 | 550 | this->filebin.push_back(0); 551 | this->filebin.push_back(0); 552 | this->filebin.push_back(0); 553 | this->filebin.push_back(0); 554 | } 555 | } 556 | } 557 | this->offset += (mnemonic.size()-1)*8; 558 | mnemonic.clear(); 559 | keyl = true; 560 | } 561 | 562 | if(mnemonic[0].item == ".org") 563 | { 564 | if(mode == 1) 565 | { 566 | if(this->target == TARGET_65816) 567 | { 568 | n = this->offset&0x7FFF; 569 | 570 | this->snesromfree += (0x8000 - n); 571 | 572 | if( (n != 0) && (n != 0x7FB0)) 573 | std::cout << "bloc size "<< ( (this->offset>>16)&0x7F)<<": "<< (this->offset&0x7FFF) << " (" << (0x8000 - n) <<") \n"; 574 | } 575 | else 576 | { 577 | 578 | //std::cout << "bloc size "<< this->offset << "\n"; 579 | } 580 | 581 | } 582 | 583 | 584 | if(mnemonic[1].token1 == '$') 585 | this->offset = std::stoll(mnemonic[1].item, 0, 16); 586 | else 587 | this->offset = std::stoll(mnemonic[1].item); 588 | 589 | if(mode == 1) 590 | { 591 | n = this->offset - this->filebin.size(); 592 | for(int i = 0;i < n;i++) 593 | this->filebin.push_back(0); 594 | 595 | } 596 | mnemonic.clear(); 597 | keyl = true; 598 | } 599 | 600 | if(mnemonic[0].item == ".rodata") 601 | { 602 | if(mnemonic[1].token1 == '$') 603 | this->offset = std::stoll(mnemonic[1].item, 0, 16); 604 | else 605 | this->offset = std::stoll(mnemonic[1].item); 606 | mnemonic.clear(); 607 | keyl = true; 608 | } 609 | 610 | if(mnemonic[0].item == ".code") 611 | { 612 | if(mnemonic[1].token1 == '$') 613 | this->offset = std::stoll(mnemonic[1].item, 0, 16); 614 | else 615 | this->offset = std::stoll(mnemonic[1].item); 616 | 617 | mnemonic.clear(); 618 | keyl = true; 619 | } 620 | 621 | if(mnemonic[0].item == ".incbin") 622 | { 623 | std::vector data; 624 | 625 | this->load_file_bin(word.c_str(),data); 626 | 627 | this->offset += data.size(); 628 | 629 | 630 | if(mode == 1) 631 | { 632 | std::vector data; 633 | 634 | this->load_file_bin(word.c_str(),data); 635 | 636 | if(data.size() > 0) 637 | { 638 | n = data.size(); 639 | 640 | for(int i = 0;i < n;i++) 641 | this->filebin.push_back(data[i]); 642 | } 643 | } 644 | 645 | mnemonic.clear(); 646 | keyl = true; 647 | word = ""; 648 | } 649 | 650 | if(mnemonic[0].item == "..begin") 651 | { 652 | 653 | if(mode == 1) 654 | { 655 | this->cyclew = mnemonic[1].item; 656 | this->cycle = 0; 657 | 658 | if(this->bmesen == true) 659 | { 660 | moffset = this->offset; 661 | mstr = mnemonic[1].item ; 662 | 663 | for (char &c : mstr) { 664 | if (c == '.') 665 | c = '_'; 666 | } 667 | } 668 | } 669 | 670 | mnemonic.clear(); 671 | keyl = true; 672 | word = ""; 673 | } 674 | 675 | if(mnemonic[0].item == "..end") 676 | { 677 | 678 | if(mode == 1) 679 | { 680 | if(this->bmesen == true) 681 | { 682 | char sline[512],shex[32]; 683 | 684 | 685 | uint64_t toff = moffset&0x10000; 686 | 687 | 688 | uint64_t off = moffset&0xFFFFF; 689 | uint64_t dif = (this->offset-1) - moffset; 690 | 691 | if(toff == 0) 692 | off -= 0x8000; 693 | else 694 | off -= 0x10000; 695 | 696 | 697 | if(this->target != TARGET_65816) 698 | { 699 | off = moffset&0xFFFFF; 700 | //uint64_t stoff = off&0xE000; 701 | 702 | dif = (this->offset) - off; 703 | } 704 | 705 | 706 | 707 | 708 | sprintf(shex,"%x-%x",(int)off,(int)(off+dif)); 709 | 710 | for(int i = 0;i < 32;i++) 711 | { 712 | if( (shex[i] >= 'a') && (shex[i] <= 'z') ) 713 | { 714 | shex[i] -= 32; 715 | } 716 | } 717 | 718 | sprintf(sline,"%s:%s:%s\n",this->mesen_rom.c_str(),shex, mstr.c_str()); 719 | this->mesen += sline; 720 | } 721 | 722 | if(bcycle == true) 723 | std::cout << std::dec << "cycle estimate "<< this->cyclew << " : " << this->cycle << std::hex <<"\n"; 724 | } 725 | 726 | mnemonic.clear(); 727 | keyl = true; 728 | word = ""; 729 | } 730 | 731 | 732 | } 733 | 734 | 735 | 736 | if(keyl == false) 737 | return 1; 738 | } 739 | } 740 | 741 | return 0; 742 | } 743 | 744 | bool Eagle::define_exist(std::string &tmp) 745 | { 746 | auto it = this->define.find(tmp); 747 | 748 | if (it != this->define.end()) 749 | return true; 750 | 751 | return false; 752 | } 753 | 754 | bool Eagle::keywords_exist(std::string &tmp) 755 | { 756 | auto it = this->keywords.find(tmp); 757 | 758 | if (it != this->keywords.end()) 759 | return true; 760 | 761 | return false; 762 | } 763 | 764 | bool Eagle::label_exist(std::string &tmp) 765 | { 766 | auto it = this->label.find(tmp); 767 | 768 | if (it != this->label.end()) 769 | return true; 770 | 771 | return false; 772 | } 773 | 774 | bool Eagle::labelbin_exist(std::string &tmp) 775 | { 776 | auto it = this->labelbin.find(tmp); 777 | 778 | if (it != this->labelbin.end()) 779 | return true; 780 | 781 | return false; 782 | } 783 | --------------------------------------------------------------------------------