Mercurial > touhou
comparison pytouhou/formats/ecl.py @ 58:3da4de9decd0
Use logging module
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 23 Aug 2011 21:01:50 +0200 |
parents | ab826bc29aa2 |
children | 4fe37a620b22 |
comparison
equal
deleted
inserted
replaced
57:694f25881d0f | 58:3da4de9decd0 |
---|---|
14 | 14 |
15 | 15 |
16 from struct import pack, unpack | 16 from struct import pack, unpack |
17 from pytouhou.utils.helpers import read_string | 17 from pytouhou.utils.helpers import read_string |
18 | 18 |
19 from collections import namedtuple | 19 from pytouhou.utils.helpers import get_logger |
20 | 20 |
21 logger = get_logger(__name__) | |
21 | 22 |
22 class ECL(object): | 23 class ECL(object): |
23 _instructions = {0: ('', 'noop?'), | 24 _instructions = {0: ('', 'noop?'), |
24 1: ('I', 'delete?'), | 25 1: ('I', 'delete?'), |
25 2: ('Ii', 'relative_jump'), | 26 2: ('Ii', 'relative_jump'), |
165 data = file.read(size - 12) | 166 data = file.read(size - 12) |
166 if opcode in cls._instructions: | 167 if opcode in cls._instructions: |
167 args = unpack('<%s' % cls._instructions[opcode][0], data) | 168 args = unpack('<%s' % cls._instructions[opcode][0], data) |
168 else: | 169 else: |
169 args = (data, ) | 170 args = (data, ) |
170 print('Warning: unknown opcode %d' % opcode) #TODO | 171 logger.warn('unknown opcode %d', opcode) |
171 | 172 |
172 ecl.subs[-1].append((time, opcode, rank_mask, param_mask, args)) | 173 ecl.subs[-1].append((time, opcode, rank_mask, param_mask, args)) |
173 | 174 |
174 | 175 |
175 # Translate offsets to instruction pointers | 176 # Translate offsets to instruction pointers |
193 sub, instr_type, size = unpack('<HHH', file.read(6)) | 194 sub, instr_type, size = unpack('<HHH', file.read(6)) |
194 data = file.read(size - 8) | 195 data = file.read(size - 8) |
195 if instr_type in (0, 2, 4, 6): # Enemy spawn | 196 if instr_type in (0, 2, 4, 6): # Enemy spawn |
196 args = unpack('<ffIhHHH', data) | 197 args = unpack('<ffIhHHH', data) |
197 else: | 198 else: |
198 print('ECL: Warning: unknown opcode %d (%r)' % (instr_type, data)) #TODO | 199 logger.warn('unknown main opcode %d (data: %r)', instr_type, data) |
199 args = (data,) | 200 args = (data,) |
200 ecl.main.append((time, sub, instr_type, args)) | 201 ecl.main.append((time, sub, instr_type, args)) |
201 | 202 |
202 return ecl | 203 return ecl |
203 | 204 |