Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7131485
Make it PEP-8 compliant
boriel May 2, 2017
855079f
Add relative imports
boriel May 2, 2017
0f5b53f
Add six module
boriel May 2, 2017
a6a9fc1
Correctly compares binary files
boriel May 2, 2017
3ff7d6c
Uses env python
boriel May 5, 2017
feffbfe
Fix for ply >= 3.5
boriel May 5, 2017
a0f1a8b
Use ply package
boriel May 5, 2017
e21b7ac
Generate own parsetab for zxb parser and lexer
boriel May 5, 2017
326a4f6
bugfix: generates byte array for py2 and py3
boriel May 5, 2017
ba42658
refact: drop deprecated __cmp__() function
boriel May 7, 2017
1f2d996
refact to make the code PEP-8 compliant
boriel May 7, 2017
a82a9ab
cleanup: remove unused import
boriel May 7, 2017
9404d55
refact: ensure the other instance is a Symbol
boriel May 7, 2017
a634587
test: update tests for ARGLIST and NUMBER
boriel May 7, 2017
86151c6
cleanup: Closer to PEP-8 compliance
boriel May 7, 2017
67ab725
refact: uses six.StringIO
boriel May 7, 2017
7252f9d
refact: uses functools and six
boriel May 7, 2017
465b021
bugfix: uses bytes array for py3 compatibility
boriel May 10, 2017
0ec61a6
bugfix: Fix potential bug of dupe elements
boriel May 10, 2017
5382a2b
update: implements union and intersection
boriel May 10, 2017
b435c11
update: better check for empty set
boriel May 10, 2017
f263bcf
refact: ensures sorted included
boriel May 10, 2017
023173f
testing: updates tests to canonical order
boriel May 10, 2017
78febf8
testing: prevents crash upon import
boriel May 10, 2017
d4e4dd0
refact: updates test so doctest comes back again
boriel May 12, 2017
b54c525
bumpversion: 1.5.0
boriel May 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[bumpversion]
current_version = 1.5.0
files = version.py

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ parsetab.py
parser.out
zxbasmtab.py
zxbpptab.py
.idea
.idea
/zxbtab.py
10 changes: 5 additions & 5 deletions api/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# the GNU General License
# ----------------------------------------------------------------------

import config
import global_
from constants import CLASS
from constants import SCOPE
from errmsg import syntax_error
from . import config
from . import global_
from .constants import CLASS
from .constants import SCOPE
from .errmsg import syntax_error


__all__ = ['check_type',
Expand Down
4 changes: 2 additions & 2 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import sys

# The options container
import options
import global_
from . import options
from . import global_

OPTIONS = options.Options()

Expand Down
4 changes: 2 additions & 2 deletions api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the GNU General License
# ----------------------------------------------------------------------

from .decorator import classproperty

__all__ = [
'ID_CLASSES', 'DEPRECATED_SUFFIXES', 'ID_TYPES',
'TYPE_NAMES', 'NAME_TYPES', 'TYPE_SIZES', 'SUFFIX_TYPE',
'PTR_TYPE'
]

from decorator import classproperty

# -------------------------------------------------
# Global constants
# -------------------------------------------------
Expand Down
7 changes: 3 additions & 4 deletions api/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
# Simple debugging module

import os
import inspect

from config import OPTIONS
from .config import OPTIONS

__all__ = ['__DEBUG__', '__LINE__', '__FILE__']

# --------------------- END OF GLOBAL FLAGS ---------------------

import inspect

def __DEBUG__(msg, level = 1):
def __DEBUG__(msg, level=1):
if level > OPTIONS.Debug.value:
return

Expand Down
4 changes: 2 additions & 2 deletions api/errmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# ----------------------------------------------------------------------

import sys
import global_
from config import OPTIONS
from . import global_
from .config import OPTIONS

# Expors only these functions. Others
__all__ = ['syntax_error', 'warning']
Expand Down
4 changes: 2 additions & 2 deletions api/global_.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# Don't touch unless you know what are you doing
# ----------------------------------------------------------------------

from opcodestemps import OpcodesTemps
from constants import TYPE
from .opcodestemps import OpcodesTemps
from .constants import TYPE

# ----------------------------------------------------------------------
# Initializes a singleton container
Expand Down
2 changes: 1 addition & 1 deletion api/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

from ast_ import NodeVisitor
from config import OPTIONS
from .config import OPTIONS
from api.errmsg import warning
import api.check as chk
from api.constants import TYPE
Expand Down
3 changes: 2 additions & 1 deletion api/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# the GNU General License
# ----------------------------------------------------------------------

from .errors import Error

TRUE = true = True
FALSE = false = False

from errors import Error

__all__ = ['Option', 'Options']

Expand Down
29 changes: 14 additions & 15 deletions api/symboltable.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@

from collections import OrderedDict

from debug import __DEBUG__
from .debug import __DEBUG__

import symbols

from symbols.symbol_ import Symbol

import global_
from config import OPTIONS
from . import global_
from .config import OPTIONS

from errmsg import syntax_error
from errmsg import warning_implicit_type
from errmsg import syntax_error_func_type_mismatch
from errmsg import syntax_error_not_array_nor_func
from .errmsg import syntax_error
from .errmsg import warning_implicit_type
from .errmsg import syntax_error_func_type_mismatch
from .errmsg import syntax_error_not_array_nor_func

from constants import DEPRECATED_SUFFIXES
from constants import SUFFIX_TYPE
from constants import SCOPE
from constants import CLASS
from constants import TYPE
from .constants import DEPRECATED_SUFFIXES
from .constants import SUFFIX_TYPE
from .constants import SCOPE
from .constants import CLASS
from .constants import TYPE

from check import is_number
from check import check_is_declared_strict
from .check import is_number
from .check import check_is_declared_strict


# ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion arch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# -*- coding: utf-8 -*-
# vim:ts=4:et:sw=4:

import zx48k
from . import zx48k
4 changes: 2 additions & 2 deletions arch/zx48k/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
# vim:ts=4:et:sw=4:

import beep
from translator import *
from . import beep
from .translator import *

import api.global_
from api.constants import TYPE
Expand Down
72 changes: 37 additions & 35 deletions arch/zx48k/beep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,67 @@
# -*- coding: utf-8 -*-
# vim:ts=4:et:sw=4:

''' This library converts duration,pitch for a beep
__doc___ = """This library converts duration,pitch for a beep
from floating point to HL,DE Integers.
'''
"""


class BeepError(BaseException):
''' Returned when invalid pitch specified (e.g. Out of Range)
'''
def __init__(self, msg = 'Invalid beep parameters'):
"""Returned when invalid pitch specified (e.g. Out of Range)
"""

def __init__(self, msg='Invalid beep parameters'):
self.message = msg

def __str__(self):
return self.message



# Pitch (frequencies) tables
TABLE = [261.625565290, # C
277.182631135,
293.664768100,
311.126983881,
329.627557039,
349.228231549,
369.994422674,
391.995436072,
415.304697513,
440.000000000,
466.163761616,
493.883301378]
TABLE = [261.625565290, # C
277.182631135,
293.664768100,
311.126983881,
329.627557039,
349.228231549,
369.994422674,
391.995436072,
415.304697513,
440.000000000,
466.163761616,
493.883301378]


def getDEHL(duration, pitch):
''' Converts duration,pitch to a pair of unsigned 16 bit integers,
"""Converts duration,pitch to a pair of unsigned 16 bit integers,
to be loaded in DE,HL, following the ROM listing.
Returns a t-uple with the DE, HL values.
'''
"""
intPitch = int(pitch)
fractPitch = pitch - intPitch # Gets fractional part
fractPitch = pitch - intPitch # Gets fractional part
tmp = 1 + 0.0577622606 * fractPitch
if not -60 <= intPitch <= 127:
raise BeepError('Pitch out of range: must be between [-60, 127]')

if duration < 0 or duration > 10:
raise BeepError('Invalid duration: must be between [0, 10]')

A = intPitch + 60
B = -5 + int(A / 12) # -5 <= B <= 10
A %= 0xC # Semitones above C
B = -5 + int(A / 12) # -5 <= B <= 10
A %= 0xC # Semitones above C

frec = TABLE[A]
tmp2 = tmp * frec
f = tmp2 * 2.0 ** B

DE = int (0.5 + f * duration - 1)
HL = int (0.5 + 437500.0 / f - 30.125)

return (DE, HL)

DE = int(0.5 + f * duration - 1)
HL = int(0.5 + 437500.0 / f - 30.125)
return DE, HL


if __name__ == '__main__':
# Simple test
print getDEHL(1, 0), [hex(x) for x in getDEHL(1, 0)]
print getDEHL(5, 0), [hex(x) for x in getDEHL(5, 0)]
print getDEHL(1.5, 15.0), [hex(x) for x in getDEHL(1.5, 15.0)]
print getDEHL(1.5, 17.0), [hex(x) for x in getDEHL(1.5, 17.0)]

print(getDEHL(1, 0), [hex(x) for x in getDEHL(1, 0)])
print(getDEHL(5, 0), [hex(x) for x in getDEHL(5, 0)])
print(getDEHL(1.5, 15.0), [hex(x) for x in getDEHL(1.5, 15.0)])
print(getDEHL(1.5, 17.0), [hex(x) for x in getDEHL(1.5, 17.0)])
Loading